Python更换索引(Index)

方法一:直接设置索引

data.index=data['索引列名']

方法二:使用.set_index

data.set_index('索引列名', drop= True, inplace=True)  # Drop:是否删掉原数据列,inplace:是否修改原dataframe

data.reset_index(drop=True)#drop:是否删掉原来的索引数据

参考链接:
Set_index
Reset_index

你可能感兴趣的:(Python,python)