How to Get Column Names of Pandas DataFrame? - Python
pythonexamples.org › pandas-dataframe-get-column-namesYou can access individual column names using the index. Python Program import pandas as pd #initialize a dataframe df = pd.DataFrame( [['Amol', 72, 67, 91], ['Lini', 78, 69, 87], ['Kiku', 74, 56, 88], ['Ajit', 54, 76, 78]], columns=['name', 'physics', 'chemistry', 'algebra']) #get the dataframe columns cols = df.columns #print the columns for i in range(len(cols)): print(cols[i])