【发布时间】:2019-03-06 01:19:13
【问题描述】:
以下 csv 由列表组成。但是,列 (2) position_start 和 (3) position_end 的列表格式不正确(即没有逗号分隔)。
我想将 csv 读入一个四列的 pandas DataFrame。
我试过下面的代码,没有成功。
position=pd.read_csv(filename, delimiter='\t',index_col=0)
CSV 文件:
,position_c,position_r_theta_phi,position_start,position_end
0,"[14.533842862081656, 0.03208616222764249, 56.92541191588316]","[58.751477765706575, 0.2499741778590546, 0.00220768246933476]",[ 19271.0805564 17808.46240249 18693.4114863 ],[ 19270.18114729 18215.86140969 18693.4114863 ]
1,"[15.565867354362126, 2.2766677669751516, 82.666319295054564]","[84.149865052813752, 0.1880523977235686, 0.1452305063941714]",[ 19301.1424449 17812.85092455 18719.15239368],[ 19242.18330777 18215.96205085 18719.15239368]
2,"[-5.4087970793661952, 8.7687766840863333, 82.903514489531517]","[83.541242779224319, 0.12364001055133951, 2.1234950828837396]",[ 19424.05948468 18127.83826079 18719.38958887],[ 19077.31693912 17913.95893244 18719.38958887]
3,"[5.4876143325782323, -5.6088702278284472, 22.368059246608027]","[23.704501909037916, 0.3373934168579211, 5.4868601633848755]",[ 19115.9817056 17864.06576253 18658.85413363],[ 19407.18754103 18148.97613687 18658.85413363]
谢谢,
飞
【问题讨论】:
-
如果您问的是关于 Python 的问题 - 在此处添加一些代码是有意义的。