Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13951

Value_counts printing wrong value

$
0
0

While working a pandas value_counts exercise, the return is never what is expected and what I need to get

The code I used is:

import pandas as pddf = pd.DataFrame({'a':[1, 1, 2, 2, 2]})value_counts = df['a'].value_counts(dropna=True, sort=True)print(value_counts)

The problem is that the code should be printing:

2    31    2Name: a, dtype: int64

But instead its printing:

a2    31    2Name: count, dtype: int64

Is there any explanation why? I'm using Jupyter if it helps. Thanks


Viewing all articles
Browse latest Browse all 13951

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>