Python中如何查看一个DataFrame对象的所有索引,列名,以及DataFrame中具体的值?
现在有一个dataframe对象df1,查看索引使用使用df1.index,查看列名使用df1.columns,查看所有的值为df1.values。
在代码中看一下:
df1=pd.DataFrame(np.arange(16).reshape(4,4),
index = pd.date_range('20200101', periods = 4),
columns=list('ABCD'))
print(df1)
输出df1的状态如下:
1.查看索引:df1.index。输出:
2.查看所有的列名:df1.columns,输出:
Index(['A', 'B', 'C', 'D'], dtype='object')