【解决办法】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