Answers for "pandas select column by names"

12

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)
Posted by: Guest on October-30-2020
0

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
Posted by: Guest on January-30-2021

Code answers related to "pandas select column by names"

Python Answers by Framework

Browse Popular Code Answers by Language