![](/img/trans.png)
[英]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.