[英]How to print the sum of cell values as a string into a new column in pandas? (IF/ELSE)
[英]How to search for a string pattern and print the total values in a column using pandas
Market Region No_of_Orders Profit Sales
Africa Western Africa 251 -12,901.51 78,476.06
Afr3ica Southern Africa 85 11,768.58 51,319.50
Africa North Africa 182 21,643.08 86,698.89
Afr2ica Eastern Africa 110 8,013.04 44,182.60
Africa Central Africa 103 15,606.30 61,689.99
Eur1ope Western Europe 964 82,091.27 656,637.14
EurYope Southern Europe 338 18,911.49 215,703.93
如何过滤和打印有错别字的总市值!! 我试过这样
-->result['Market'].str.contains(u'\|123\|').count()
masked = df['Market'].str.contains("1|2|3")
过滤:
print(df[masked])
计算:
print(masked.sum())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.