pd.read_csv设置索引行
时间: 2023-10-22 07:29:55 浏览: 146
在使用pd.read_csv函数读取csv文件时,可以通过设置index_col参数来指定作为索引的行。例如,可以使用以下代码设置索引行:obj=pd.read_csv('testdata.csv',index_col=0)。在这个例子中,将csv文件中的第一列作为行索引。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [python读取csv文件并添加索引](https://blog.csdn.net/bjwhile/article/details/115447060)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [python数据处理——pandas.read_csv()指定行索引和列索引](https://blog.csdn.net/m0_37876745/article/details/85007697)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [python pandas获取csv指定行 列的操作方法](https://download.csdn.net/download/weixin_38628243/14867367)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文