Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

get datafram colum names as list python

# Method 1
list(df)

# Method 2
df.columns.values.tolist()

# Method 3 - list comprehension
[col for col in df]
Comment

get dataframe column names

# 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)
Comment

get columbe names from data fram pandas

# to print the columns
print(df.columns)
Comment

PREVIOUS NEXT
Code Example
Python :: convert a pandas column to int 
Python :: pandas dataframe from multiple csv 
Python :: flask give port number 
Python :: df invert sort index 
Python :: find python path windows 
Python :: split every character python 
Python :: python record screen 
Python :: django rest framework delete file 
Python :: how to clear an array python 
Python :: python date + days 
Python :: sort by column dataframe pyspark 
Python :: import matplotlib python 
Python :: classe statistique dataframe python 
Python :: python how to check which int var is the greatest 
Python :: python scatterplot figsize 
Python :: bring tkinter window to front 
Python :: python import stringio 
Python :: how to plotting points on matplotlib 
Python :: none address in python 
Python :: how to get sum specific columns value in machine learning 
Python :: df order by 
Python :: find matches between two lists python 
Python :: conda python-telegram-bot 
Python :: pyspark add string to columns name 
Python :: create additional rows for missing dates pandas 
Python :: python imread multiple images 
Python :: text to binary python 
Python :: python date from yy/mm/dd to yy-mm-dd 
Python :: pil image from numpy 
Python :: adaptive thresholding python 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =