How to get the number of times a piece if word is inside a particular column in pandas?

前端 未结 2 335
无人共我
无人共我 2021-01-20 01:43

I\'ll try to use a simple example to describe my problem.

I have a csv file with many columns. One of this columns\' header is \"names\".

In this column \"n

2条回答
  •  一整个雨季
    2021-01-20 02:30

    Using str.contains

    df.Name.str.contains('John').sum()
    Out[246]: 3
    

    Or we using list and map with in

    sum(list(map(lambda x : 'John' in x,df.Name)))
    Out[248]: 3
    

提交回复
热议问题