pandas set_index和reset_index

mport pandas as pd
df_a = pd.DataFrame(data=[['A', 'B', 'C'], ['A1', 'B1', 'C1']], columns=['first', 'second', 'third'])
print(df_a)
df_a.set_index(['first','second'],inplace=True)
print(df_a)
df_a.reset_index()
print(df_a)
df_a.reset_index(drop=True)
print(df_a)
df_a.reset_index(inplace=True)
print(df_a)

pandas set_index和reset_index_第1张图片
pandas set_index和reset_index_第2张图片

pandas set_index和reset_index_第3张图片

你可能感兴趣的:(python数据处理,python)