Vince Miller Vince Miller -4 years ago 45
Python Question

Indexing a series in python pandas

Below I have listed what my object countiespop returns as well as the type of the object. I cannot find a way to create a series of exclusively the 3 'STNAME'.

countiespop

Returns
STNAME
California 15924150
Texas 8269632
Illinois 6815061
Name: CENSUS2010POP, dtype: int64


type(countiespop)


Returns
pandas.core.series.Series

Answer Source

Is this what you are after?

#create a series using the index of the current Series
pd.Series(countiespop.index)
Out[274]: 
0    California
1         Texas
2      Illinois
Name: a, dtype: object
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download