python - can't chart what I want to chart with .hist() in Pandas -
simple question. it's quite basic. have pandas dataframe named firstperiod
, column named megaball
. range of values in megaball
1 25, , line of code:
print firstperiod.megaball.value_counts().sort_index()
gives me this, want 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 go to make basic histogram of this, using
firstperiod.megaball.value_counts().sort_index().hist() plt.show()
the chart isn't want @ (max y-value 6 when should 15, x-axis goes 16). doing wrong?
you don't want histogram of values, want plot them as-is. try:
firstperiod.megaball.value_counts().sort_index().plot(kind='bar')
you may have fiddle other plot options plot how want.
Comments
Post a Comment