DATA VISUALIZATION Roller Coaster | creating bins with value counts

Hello,
I´m trying to make a function that is able to create histograms depending on the selected column of the DB.
I´m trying to get this done by using value counts with bins, but the resulting series gives a range and the number of time the values are within the range, this is exactly what I need to make a histogram, but I don´t understand how to plot it, the graph makes no sense.
Please help.

import codecademylib3 from matplotlib import pyplot as plt import pandas as pd import numpy as np coasters=pd.read_csv('roller_coasters.csv') binos=coasters[column].value_counts(bins=10, sort=False) ax=plt.subplot() plt.hist(binos) plt.show()

binos=coasters[column].value_counts(bins=10, sort=False)

ax=plt.subplot()

plt.hist(binos)

plt.show()

I’d suggest printing the output from plt.hist(binos) so you know what bins/counts are actually being plotted. You might find dataframes don’t always fit the type,shape etc. you expected so it’s worth double checking.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.