I hope this is not too trivial, but I am kind of stuck. I am trying to count how many times the word "dog" appears in each row of a data frame. I then want to add the number in a new column.
This is how the dataframe looks like at the moment:
df_start = pd.DataFrame({'col1': ['House Home Dog', 0, 'Dog Flower Cat'], 'col2': ['Flower', 0, 0], 'col3': ['House Dog', 0, 'Dog Cat']})
I want to count how many times the word "dog" occurs in each row over multiple columns (in the final dataset I have more than 100 columns). The final result should look sth like this:
df_final = pd.DataFrame({'col1': ['House Home Dog', 0, 'Dog Flower Cat'], 'col2': ['Flower', 0, 0], 'col3': ['House Dog', 0, 'Dog Cat'], 'col4':[2, 0, 2]})
So far I am able to count the number of non null cells for each row or count how many times the word occurs in each column. But not the desired outcome. Thank you in advance for your help.