I have a list:
things = ['A1','B2','C3']
I have a pandas data frame with a column containing values separated by a semicolon - some of the rows will contain matches with one of the items in the list above (it won't be a perfect match since it has other parts of a string in the column.. for example, a row in that column may have 'Wow;Here;This=A1;10001;0')
I want to save the rows that contain a match with items from the list, and then create a new data frame with those selected rows (should have the same headers). This is what I tried:
import re
for_new_df =[]
for x in df['COLUMN']:
for mp in things:
if df[df['COLUMN'].str.contains(mp)]:
for_new_df.append(mp) #This won't save the whole row - help here too, please.
This code gave me an error:
ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
I'm very new to coding, so the more explanation and detail in your answer, the better! Thanks in advance.