Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python return column names of pandas dataframe

# Basic syntax:
your_dataframe.columns

# Note, if you want the column names as a list, just do:
list(your_dataframe.columns)
Comment

pd dataframe get column names

lst = data.columns.values     # data is dataframe
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

Show column names and indexes dataframe python

import pandas as pd

# Dataframe example
df = pd.DataFrame({'col_A':[1,5,7,8],'col_B':[9,7,4,3], 'col_C':[5,1,4,9]})

# Showing all column names and indexes for df
print(* (f"{i}: {col}" for i,col in enumerate(df.columns)), sep='
')
Comment

PREVIOUS NEXT
Code Example
Python :: Sys Gets os name ,which u using 
Python :: login system in django 
Python :: Heroku gunicorn flask login is not working properly 
Python :: sys.argv python example 
Python :: python array empty 
Python :: is enumerate python lazy 
Python :: jsonpath in python verwenden 
Python :: 2--2 in python prints? 
Python :: sum two linked lists if numbers are reversed in linked list 
Python :: locate certificate path python 
Python :: how to count the iteration a list python 
Python :: input list in function and display column in dataframe python 
Python :: Python - Comment Parse String to List 
Python :: how to join two string series python 
Python :: pandas form multiindex to column 
Python :: exception: python in worker has different version 3.7 than that in driver 3.8, pyspark cannot run with different minor versions. please check environment variables pyspark_python and pyspark_driver_python are correctly set. 
Python :: how to stop a while loop in opencv 
Python :: python deep setter 
Python :: Update only keys in python 
Python :: sqlite3.operationalerror no such column version 
Python :: or without file pythonmodules.txt 
Python :: python function changing arguments 
Python :: python [a]*b means [a,a,...b times] 
Python :: asserts pytest for function called more than once 
Python :: factorielle python 
Python :: jama python rest api 
Python :: how to save multiple choices in django site:stackoverflow.com 
Python :: combine all lines with same value of a column unix 
Python :: cbv uk django 
Python :: pandas condense dataframe by summing according to ID 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =