Splitting dictionary/list inside a Pandas Column into Separate Columns

后端 未结 12 1461
南方客
南方客 2020-11-22 02:50

I have data saved in a postgreSQL database. I am querying this data using Python2.7 and turning it into a Pandas DataFrame. However, the last column of this dat

12条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 03:31

    I know the question is quite old, but I got here searching for answers. There is actually a better (and faster) way now of doing this using json_normalize:

    import pandas as pd
    
    df2 = pd.json_normalize(df['Pollutant Levels'])
    

    This avoids costly apply functions...

提交回复
热议问题