Skip to content
Advertisement

How to convert a list with dictionaries into new pandas columns?

I have a dataframe which has a list of dictionaries as a column: This column has the following format:

JavaScript

How can I convert this column into 4 new columns? I mean: route_id (x2), stop_id(x2) as new columns.

Thanks in advance!

Advertisement

Answer

You can use df.explode with df.apply:

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