I am trying to use pandas.Series.value_counts to get the frequency of values in a dataframe, so I go through each column and get values_count , which gives me a series:
If you want to convert a Series
to a dict
, you could call dict
or .to_dict()
:
>>> s
high 3909
average 3688
less 182
veryless 62
dtype: int64
>>> type(s)
>>> dict(s)
{'high': 3909, 'average': 3688, 'veryless': 62, 'less': 182}
>>> s.to_dict()
{'high': 3909, 'average': 3688, 'veryless': 62, 'less': 182}