The Situation:
I have a pandas DataFrame and would like to find all the entries of a certain columnn with a string that contains a specific word more than once and create a separate dataframe with from said results.
What have I done?
So far I have managed to get it to collect all the entries that contain the specified word at least once.
The Code:
import pandas as pd
df = pd.DataFrame({'Year': ['2020', '2021', '2021'],
'Title': ['Energy calculation', 'Energy calculation with energy', 'Other calculation'])
terms = ['energy']
list_df = selection_df[selection_df['title'].str.contains('|'.join(terms), na=False, case=False)]
The output:
0 2020 Energy calculation 1 2021 Energy calculation with energy
Then question
I would like help in collecting only the second entry:
1 2021 Energy calculation with energy
Which contains the word energy more than once. How could I do this?