dataframe = pd.DataFrame(np.random.rand(6,4),columns=list(‘ABCD’))
print(dataframe)
ColNames = dataframe.columns
print(ColNames,type(ColNames)) # 注意ColNames的类型是object
ColNames_List = dataframe.columns.tolist()
print(‘------------------------------------------------------’)
print(ColNames_List,type(ColNames_List))
ColNames = dataframe.columns.values
print(ColNames,type(ColNames)) # 注意ColNames的类型是numpy.ndarray
ColNames_List = dataframe.columns.values.tolist()
print(‘------------------------------------------------------’)
print(ColNames_List,type(ColNames_List))