Home > Software design >  How to flatten a dataframe column into columns and filter it?
How to flatten a dataframe column into columns and filter it?

Time:01-03

I converted a JSON file into a Pandas dataframe.

Dataframe

I want to flatten the 'pos' column into the following columns and filter it:

Result

What should I do?

CodePudding user response:

You can use:

df['word']=df['pos'].apply(lambda x: x[4]['word'])
df['tag']=df['pos'].apply(lambda x: x[3])
  • Related