【发布时间】:2022-11-28 09:42:51
【问题描述】:
我正在尝试将位置列中的值拆分为 csv 文件中的两个不同的 x 和 y 列
现在它看起来像这样:
location
[60.0, 56.0]
[68.0, 74.0]
[58.0, 52.0]
[63.0, 53.0]
[119.0, 79.0]
我希望它拆分列并获得两个不同的列并删除括号,以便列看起来像这样:
x y
60 56
68 74
58 52
63 53
119 79
我所有这些: 1.
df[['x', 'y']] = pd.DataFrame(df['location'].tolist(), index=df.index)
pd.concat([df[[0]], df['location'].str.split(',', expand=True)], axis=1
df['location'].str.split(',', expand=True)
但是收到错误
【问题讨论】: