1

I have a list with this format

[{'label': 'Negative', 'score': 0.640342652797699},
{'label': 'Neutral', 'score': 0.6779775619506836},
{'label': 'Positive', 'score': 0.6488891839981079},
{'label': 'Negative', 'score': 0.8951766490936279},
{'label': 'Neutral', 'score': 0.5843858122825623},
{'label': 'Negative', 'score': 0.9183987379074097},
{'label': 'Neutral', 'score': 0.6507250666618347}]

I would like to create a data frame with this information, whit a column called sentiment and the other one called score

dataframe:

sentiment  *   score
*********************
Negative   *  0.640342652797699
Neutral    *  0.6779775619506836
Positive   *  0.6488891839981079
 ....           ....

I am not suure how can I transform my list to a data frama with this structure

coding
  • 917
  • 2
  • 12
  • 25

1 Answers1

1

you can create DataFrame then rename column name like below:

>>> pd.DataFrame(lst_dct).rename({'label': 'sentiment'}, axis=1)
I'mahdi
  • 23,382
  • 5
  • 22
  • 30