嗨,有以下熊猫df:
import pandas as pd
# intialise data of lists.
data = {'Name':['Anthony made with sangiovese merlot and ', 'forest floor menthol espresso cranberry and ', 'from the warm vintage this is a soft and', 'this densely hued wine ha aroma of black'], 'Age':[20, 21, 19, 18]}
# Create DataFrame
df = pd.DataFrame(data)
df.head()
我要提取所有名词和调整。我使用:
from textblob import TextBlob
def get_adjectives(text):
blob = TextBlob(text)
return [ word for (word,tag) in blob.tags if tag=="NN" & tag=='NN']
df['adjectives'] = df['Name'].apply(get_adjectives)
df.head()