I'm trying to filter the contents of a dataframe. If a string is present in a column, those rows have to be stored in a new dataframe
list1 = ['A+B','A']
list2 = ['1','2']
df = pd.DataFrame(
{
'name':list1,
'value':list2
}
)
temp_df = df[df.name.str.contains('A')]
pprint(temp_df)
Output obtained:
name value
0 A+B 1
1 A 2
Desired output:(only those that have an exact match)
name value
0 A 2
Any suggestions on how this can be achieved?