# Empty Dataframe

FandangoMovieRatingsUpdate-Copy1.ipynb (118.2 KB)

My Code:
plt.style.use('fivethirtyeight')

stats['2015'].plot.bar(label='2015')
stats['2016'].plot.bar(label='2016')
plt.show()

What I expected to happen:

Bar plots of the data.
What actually happened:

TypeError: Empty 'DataFrame': no numeric data to plot

I printed the dataframe in the previous step and it includes the mean, median, and mode.

Click here to view the jupyter notebook file in a new tab

2 Likes

Hey @vroomvroom

To solve this problem, you need to convert the specific column or columns that you want to use numerically. The below code should solve your problem.

stats[â€ś2015â€ť].plot.barh
stats[â€ś2016â€ť].plot.barh
plt.title(â€śSummary statistics of samplesâ€ť, y=1.05)
plt.xlim(0, 5)
plt.xlabel(â€śStarsâ€ť)
plt.xticks(np.arange(0,5.5,.5))
plt.show()

Let me know if that works.

Best
K!

1 Like

hey @vroomvroom,

Here mode is messing with your dataframe stats because its return Series If you see library documentation for method mode- here It return pandas.Series not a value. (There can be multiple mode possible so)

Hence to select first mode for example we can do mode15[0].

stats = pd.DataFrame()
stats['2015'] = [mean_15, median_15, mode_15[0]]
stats['2016'] = [mean_16, median_16, mode_16[0]]
...

After creating stats using above code it should work.

3 Likes

Thank you @DishinGoyani and @prasadkalyan05 !

1 Like