python select columns names from dataframe 1

python select columns names from dataframe

# Import pandas package  
import pandas as pd  
    
# making data frame  
data = pd.read_csv("nba.csv")  
  
# iterating the columns 
for col in data.columns: 
    print(col) 

Here is what the above code is Doing:
1. We first import the pandas module.
2. Then we read the CSV file using the read_csv() method.
3. Next, we iterate over the columns of the dataframe using the for loop.
4. Finally, we print the column names.

Similar Posts