【发布时间】:2023-03-13 12:30:01
【问题描述】:
我需要使用 pandas 0.7.3 将 csv 导入 python 的帮助 我可以将数据输入 python,但这些列作为一列读入。查看示例 下面。
In [12]: data=pd.read_csv(file)'
In [13]: data[:3]
Out[13]:
Area Circ. AR Round Solidity
0 1 31650 0.368 2.973 0.336 0.683
1 2 6875 0.836 1.181 0.847 0.924
2 3 12850 0.767 1.543 0.648 0.902
In [14]: data.columns
Out[14]: Index([ Area Circ. AR Round Solidity], dtype=object)
如何导入数据,得到如下数据结构
In [14]: data.columns
Out[14]: Index([Area, Circ., AR, Round, Solidity,], dtype=object)
这样
In [15]:data['area']
Out[15]:
31650
6875
12850
etc
谢谢。
【问题讨论】:
-
显示文件中的数据,使用
sep=定义分隔符。
标签: python csv pandas multiple-columns