Pie chart for frequency distribution (Screen 5)

Screen Link: Learn data science with Python and R projects

My Code:

import matplotlib.pyplot as plt

wnba['Exp_ordinal'].value_counts().plot.pie(figsize = (6, 6), autopct = '%.2f%%', title = 'Percentage of players in WNBA by level of experience')
plt.ylabel('')

What I expected to happen:
Expected it to generate pie chart

What actually happened:

TypeErrorTraceback (most recent call last)
<ipython-input-1-5b8129dd1d7b> in <module>()
      2 
      3 wnba['Exp_ordinal'].value_counts().plot.pie(figsize = (6, 6), autopct = '%.2f%%', title = 'Percentage of players in WNBA by level of experience')
----> 4 plt.ylabel('')

TypeError: 'str' object is not callable

I believe the issue is in the last line of my code. However, I think its the same as the solution provided by DQ. Am I missing something? Thanks in advance!

This happened to me before.

It’s probably because you accidentally reassigned plt to something else, most likely a string.

Try running the following before the plt.ylabel

from importlib import reload
reload(plt)
# your code here e.g. plt.ylabel('')

Here’s the thread about the issue: How do I reload a Python library?

1 Like

The issue was solved when I opened the platform the next morning. Thanks though!

1 Like

That’s great to hear.

It’s probably because they reset the variables of your code after each day or two, so the plt module is back to normal.

You can clear all variables in jupyter by typing

%reset

and evaluating that cell with shift-enter or any other means.

1 Like