标签:frame 函数 range ict data col and ace dataframe
一、rename,更改df的列名和行索引
1 df=pd.DataFrame(np.arange(1,10).reshape(3,3)) 2 print(df) 3 print(type(df)) 4 结果为: 5 0 1 2 6 0 1 2 3 7 1 4 5 6 8 2 7 8 9 9 <class ‘pandas.core.frame.DataFrame‘> 10 11 my_col=dict(zip(range(3),[‘A‘,‘B‘,‘C‘])) 12 df.rename(columns=my_col,inplace=True) 13 print(df) 14 print(type(df)) 15 结果为: 16 A B C 17 0 1 2 3 18 1 4 5 6 19 2 7 8 9 20 <class ‘pandas.core.frame.DataFrame‘>
标签:frame 函数 range ict data col and ace dataframe
原文地址:https://www.cnblogs.com/xinyangq/p/12376338.html