I have a dataframe:
import pandas as pd
df = pd.DataFrame({'letter': ['A','A','B','B','C','C'],
'value':[ 1, 2, 3, 3, 7, 5],
'state':['CA','WA','WA','WA','CA','NV']})
Count how many times a value appears in the state column:
df['state'].value_counts()
This is a pandas.core.series.Series (according to type(df['state'].value_counts()). So:
df['state'].value_counts()[0]
Only returns 3, not WA 3.
How do I get the name of the entries value_counts() counts? ie how do I get WA?
I intend this as a self-answered question, if there are better answers, they are welcome.

