如何在 pandas 中读取没有标题的csv [英] How to read csv without header in pandas
本文介绍了如何在 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.
这篇关于如何在 pandas 中读取没有标题的csv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文