Pandas: split column of lists of unequal length into multiple columns

前端 未结 2 544
我在风中等你
我在风中等你 2020-12-07 21:58

I have a Pandas dataframe that looks like the below:

                   codes
1                  [71020]
2                  [77085]
3                  [36415         


        
2条回答
  •  悲哀的现实
    2020-12-07 22:46

    Another solution:

    In [95]: df.codes.apply(pd.Series).add_prefix('code_')
    Out[95]:
        code_0   code_1   code_2
    1  71020.0      NaN      NaN
    2  77085.0      NaN      NaN
    3  36415.0      NaN      NaN
    4  99213.0  99287.0      NaN
    5  99233.0  99233.0  99233.0
    

提交回复
热议问题