计算大熊猫数据帧中字符的最大出现次数
答
使用str.count
和然后找到它max
:
finefoods_df['Review'].str.count('!').max()
演示
df
A
0 hi!
1 hello!!
2 bye!!!
df.A.str.count('!')
0 1
1 2
2 3
Name: A, dtype: int64
df.A.str.count('!').max()
3
完美,谢谢!我之前就有过,只是觉得它看起来很奇怪,而且我错过了.str。我会接受这个答案一旦我可以 –
@ J.McCraiton不要忘记[投票,并接受答案](https://stackoverflow.com/help/someone-answers)。谢谢:) –
Woops我的坏!你走了! –