How can I create a new pandas data frame from an existing data frame based on multiple partial string matches of values in one column?
For example if I had a data frame with one column that contains the partial strings of "Commercial", "Corporate", Private", I would like to create a new data frame with only rows that contain the partial strings of "Commercial" and "Corporate" while ignoring the rows that have the partial string of private.
Currently I am trying the code
df = df[(df['text'].str.contains("Commercial") or
df['text'].str.contains("Corporate") or
df['text'].str.contains("SME"))]
but it gives me an error of
The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().