Dataframe column values

import pandas as pd

# Create data frame from csv file
df=pd.read_csv(“e://data/state-population.csv”)

# Dataframe column values 

df[[‘year’, ‘population’]].head()

# Dataframe column values
df.values

Output

array([[‘AL’, ‘under18’, 2012, 1117489.0], [‘AL’, ‘total’, 2012, 4817528.0], [‘AL’, ‘under18’, 2010, 1130966.0], …, [‘USA’, ‘total’, 2011, 311582564.0], [‘USA’, ‘under18’, 2012, 73708179.0], [‘USA’, ‘total’, 2012, 313873685.0]], dtype=object)

  year
0 2012 1117489.0
1 2012 4817528.0
2 2010 1130966.0
3 2010 4785570.0
4 2011 1125763.0

Published by Python programming examples for beginners

Abhay Gadkari is an IT professional having around experience of 20+ years in IT industry. He worked on web technologies and databases with Insurance and ERP projects.