Run
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 column names cols = df.columns # Print the column names using For loop for column in cols: print(column)
Output