Reputation: 4256
simple question. hopefully it's really quite basic. I have a pandas dataframe named firstperiod
and a column named megaball
. The range of the values in megaball
are from 1 to 25, and this line of code:
print firstperiod.megaball.value_counts().sort_index()
gives me this, which is what I want to see (the # of occurrences per possible value)
1 12
2 4
3 9
4 4
5 3
6 6
7 5
8 8
9 7
10 10
11 6
12 5
13 3
14 5
15 6
16 8
17 15
18 7
19 8
20 5
21 8
22 7
23 1
24 11
25 9
But when I go to to make a basic histogram of this, using
firstperiod.megaball.value_counts().sort_index().hist()
plt.show()
the chart isn't what i want at all (max y-value is 6 when it should be 15, x-axis only goes to 16). What am i doing wrong?
Upvotes: 0
Views: 104
Reputation: 251383
You don't want to do a histogram of those values, you just want to plot them as-is. Try:
firstperiod.megaball.value_counts().sort_index().plot(kind='bar')
You may have to fiddle with other plot options to get the plot to look exactly how you want.
Upvotes: 2