Skip to content
Advertisement

Column dictionary values into separate Dataframe

I have a dataframe which has a column that contains a list of dictionaries. This is what an example column value it looks like:

JavaScript

I want to create a separate dataframe that takes the above column values for each row, and produces a dataframe where ‘category’ is a column, and the values for that columns are score and threshold.

For example:

JavaScript

Advertisement

Answer

Assuming lst the input list, simply use the DataFrame constructor:

JavaScript

output:

JavaScript

If you have such list for each item in the series, use itertools.chain:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement