简体   繁体   English

将包含 Float64 值的 1 个 DataFrame 列拆分为几个

[英]Split 1 DataFrame column containing Float64 values into several

I have a DataFrame where I want to split the float64 list values into separate columns.我有一个 DataFrame 我想将 float64 列表值拆分为单独的列。 The current DataFrame looks like:当前的 DataFrame 看起来像:

                                    0
Fp1   [0.17447164115148173, 0.06726957143085581, 0.17298492547895647, 0.10928149060730677]
F3    [0.15979351009681514, 0.11017144893549853, 0.16213662211559293, 0.10816689203332136]...

I would like to split the one column into 4 so:我想将一列分成 4 列,所以:

        0                       1                   2                    3
Fp1   [0.17447164115148173] [0.06726957143085581] [0.17298492547895647] [0.10928149060730677]
F3    [0.15979351009681514] [0.11017144893549853] [0.16213662211559293] [0.10816689203332136]...

I have found things close to solving the problem (like using pd.str.split() etc but they do not work because the data format in the columns at the moment is float64.我找到了接近解决问题的方法(例如使用 pd.str.split() 等,但它们不起作用,因为目前列中的数据格式是 float64。

Any help appreciated, thankyou!任何帮助表示赞赏,谢谢!

You can try this你可以试试这个

df[0].apply(pd.Series)

or或者

df.apply(lambda x: pd.Series(x[0]), axis=1)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM