【解决办法】read_csv()第一列作为index
生活随笔
收集整理的这篇文章主要介绍了
【解决办法】read_csv()第一列作为index
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
简述
在之前读取csv文件的时候,发现第一列被读到了dataframe的column中了,而不是读到了index中,查阅完文档后得到解决。
解决办法
- index_col : int or sequence or False, default None
* Column to use as the row labels of the DataFrame. If a sequence is given, a MultiIndex is used. If you have a malformed file with delimiters at the end of each line, you might consider index_col=False to force pandas to not use the first column as the index (row names)
比如说,下面这个代码就可以解决了~
将第一列变为index。这样的读取进来~
总结
以上是生活随笔为你收集整理的【解决办法】read_csv()第一列作为index的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: DeprecationWarning:
- 下一篇: pandas.DataFrame.mul