赞
踩
'Unnamed:0'
解决方案1:
read_csv()时候,设置index_col=0即可。pd.read_csv(path,index_col=0)
解决方案2:
to_csv()时候,设置index=False。或者加上index=True, index_label=“id”df.to_csv(path,index=False)
或者df.to_csv(path,index=True, index_label="id")
- import numpy as np
- import pandas as pd
- data1=pd.read_csv('test.csv')
- data1.head(2)
- data1=data1.drop('Unnamed: 0',1)
- data1.to_csv('aaa.csv',index=False)
- data1=pd.read_csv('aaa.csv')
- data1.head(2)
- data1=pd.read_csv('test.csv')
- data1=data1.drop('Unnamed: 0',1)
- data1.to_csv('aa.csv',index=True, index_label="id")
- data1=pd.read_csv('aaa.csv')
- data1.head(2)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。