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

select specific column names from dataframe

import pandas
data = pandas.DataFrame({'A' : ['X', 'Y'], 
                        'B' : 1, 
                        'C' : [2, 3]})
print data[['A', 'B']]

# Output   A  B
# 0  X  1
# 1  Y  1
Comment

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

get columbe names from data fram pandas

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

PREVIOUS NEXT
Code Example
Python :: how to check if object is of file type in python3 
Python :: dict ;get a key of a value 
Python :: intersection of two lists using set method 
Python :: pandas excelfile 
Python :: telegram.ext module python 
Python :: tkinter set text 
Python :: subplot ytick percent 
Python :: how to make colab reload on form change 
Python :: add prefix to names in directory python 
Python :: python puissance 
Python :: matplotlib remove white lines between contour 
Python :: how to append dict to dict in python 
Python :: python vs java 
Python :: get all functions from a module as string list python 
Python :: 1 12 123 python 
Python :: python decomposition facteur premier 
Python :: any python type hint 
Python :: df dtype 
Python :: Connect to MySQL Using Connector Python C Extension 
Python :: pytorch tensor argmax 
Python :: ascii to int python 
Python :: access icloud doc on jupyter notebook 
Python :: get sum of column before a date python 
Python :: python sort() and sorted() 
Python :: run django server on any network address of the system 
Python :: np append 
Python :: what is cpython 
Python :: python word encode asci 
Python :: deletion in a binary search tree 
Python :: ljust rjust center python 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =