79201337

Date: 2024-11-18 20:29:31
Score: 1
Natty:
Report link

This code create a new column with word having 'NN' post tag:

import pandas as pd
post = [[('word1', 'NN'), ('word2', 'VB'), ('word3', 'NN')],[('word4', 'JJ'), ('word5', 'NN')]]
df = pd.DataFrame({'TEXT':['text'],'POST':[post]})
df['WORDS_NN'] = df['POST'].map(lambda post_data : [p[0] for line in post_data for p in line if p[1]=='NN'])
df

enter image description here

Out of this, try to read about python spacy. its very usefull for NLP like Post tag filters

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: camilo_chart