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

python pandas return column name of a specific column

# Basic syntax:
list(df.columns)[column_number]
# This returns the column name of the column of interest
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

PREVIOUS NEXT
Code Example
Python :: decode utf8 whit python 
Python :: autopytoexe 
Python :: cv2.imwrite 
Python :: python sum 
Python :: register template tag django 
Python :: Splitting strings in Python without split() 
Python :: discord py fetch message 
Python :: calculate quartil python 
Python :: pyton do while loop+ 
Python :: django admin.py 
Python :: python index method 
Python :: how to pick everything after a character in python 
Python :: swap in python 
Python :: dataframe shift python 
Python :: how to read linux environment variable in python 
Python :: print example in python 
Python :: python access each group 
Python :: rotate 2d array 
Python :: How to develop a UDP echo client? 
Python :: remove from list if not maches in list 
Python :: ValueError: cannot convert float NaN to integer 
Python :: iterate over a set python 
Python :: pandas count number of repetitions of each diferent value 
Python :: how to use drf permission class with class method actions 
Python :: string upper lower count python 
Python :: Check np.nan value 
Python :: save image to database using pillow django 
Python :: get char from ascii value python 
Python :: installing python3.9 on linux mint 20 
Python :: python how to insert values into string 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =