dataframe = pd.DataFrame(np.random.rand(6,4),columns=list(‘ABCD’))
print(dataframe)
1. Get the column names of dataframe: dataframe.columns
ColNames = dataframe.columns
print(ColNames,type(ColNames)) # NoticeColNamesThe type isobject
ColNames\_List = dataframe.columns.tolist()
print(‘------------------------------------------------------’)
print(ColNames\_List,type(ColNames\_List))
1.2 Get the column names of dataframe: dataframe.columns.values
ColNames = dataframe.columns.values
print(ColNames,type(ColNames)) # NoticeColNamesThe type isnumpy.ndarray
ColNames\_List = dataframe.columns.values.tolist()
print(‘------------------------------------------------------’)
print(ColNames\_List,type(ColNames\_List))