I'm reading a large CSV file and one of the columns has below representation.
import pandas as pd
df['col1'] = pd.Series(
["37", "AWESOME House", "Yellow Cottage, 107", "14"], dtype='object'
)
My code uses "vectorized string methods" to return desired data in timely fashion.
Simplified code to illustrate some parts of logic.
import numpy as np
sth = np.where(
<check condition>,
df['col1'].str.lower(),
df['some_other_column'].whatever()
)
Next I'd like to check if each value in my Series contains any element from below list.
check_list = ['a', 'b', 'c']
So expected result (for "check condition") would be:
False
True
True
False
I tried this
np.where(
np.any([x in df['col1'].str.lower() for x in check_list])
...
but received error:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
How could I solve my problem correctly?