Let's say my dataframe looks like this:
column_name
1 book
2 fish
3 icecream|book
4 fish
5 campfire|book
Now, if I use df['column_name'].value_counts()
it will tell me fish
is the most frequent value.
However, I want book
to be returned, since row 1, 3 and 5 contain the word 'book'.
I know .value_counts()
recognizes icecream|book
as one value, but is there a way I can determine the most frequent value by counting the amount of times each column cell CONTAINS a certain value, so that 'book' will the most frequent value?