I would like to extract keywords from the column df[“description”], such as “apple” and “banana”, and append it under the list output
, I tried:
def kw(df):
output = []
apple = np.NaN
if (df['description'].str.contains('apple', na = False)):
output.append(output)
if (df['description'].str.contains('banana', na = False)):
output.append(output)
return output
df['kw'] = df.apply(kw)
but it caught the but caught the error AttributeError: 'str' object has no attribute 'str'