pandas读取csv数据时设置index

比如读取数据时想把第一列设为index,那么只需要简单的

pd.read_csv("new_wordvecter.csv",index_col=[0]) 

 这里index_col可以设为列名

后续更改index可以使用df.index = df.iloc[:,"column"].tolist()或df.set_index('column')

 

原文地址:https://www.cnblogs.com/dylan9/p/8994087.html