如何在 pandas 中读取没有标题的csv
问题描述:
我用
Adj = pd.read_csv('xxxxxx.csv', usecols=["Adj Close"])
读取我的 csv 文件,结果如下:
to read my csv file and result is looks like:
Adj Close
0 0.007427
1 0.002013
2 0.008874
我的 csv 文件看起来像:
my csv file look like:
Date Open High Low Close Volume Adj Close
x x x x x 832.349976
x x x x x 832.349923
我试图得到如下结果:
0 0.007427 or 0.007427
1 0.002013 0.002013
2 0.008874 0.008874
我该怎么办?谢谢!
答
读取没有标题的 csv 文件,操作如下:
To read a csv file without header, do as follows:
data = pd.read_csv(filepath, header=None)
正如 EdChum 评论的那样,问题并不清楚.但这是搜索读取没有标题的 csv 文件时的第一个谷歌结果.所以,我为此添加了一个解决方案,以防其他人来到这里寻找解决方案.
As EdChum commented, the questions isn't clear. But this is the first google result when searching for reading a csv file without header. So, I've added a solution for that, in case somebody else lands here looking for a solution for that.