TypeError: 'numpy.float64' object is not callable

Screen Link: https://app.dataquest.io/m/283/sampling/5/simple-random-sampling

My Code:

import pandas as pd
import matplotlib.pyplot as plt

wnba = pd.read_csv('wnba.csv')
sample_means = []
population_mean = wnba['PTS'].mean()

for i in range(100):
    sample = wnba['PTS'].sample(10, random_state=i)
    sample_means.append(sample.mean())

plt.scatter(range(1,101), sample_means)
plt.axhline(population_mean)

What actually happened:

TypeError: 'numpy.float64' object is not callable

I’m getting this error on the plt.axhline() line. I’ve tried running with my code and with the answer and the error persists. It seems like the plt.axhline is being read as a numpy.float64 object.

Thank you!

2 Likes

Hi @guilherme.tmiranda:

I was able to run your code and it was accepted successfully. Do you mind refreshing your screen?

1 Like

It seems you have redefined or reassign library method by mistake. You can reload module again by

import matplotlib.pyplot as plt

from importlib import reload
reload(plt)

Let us know if issue still persists. :slight_smile:

More you can also refer this topic

4 Likes

I’ve reloaded plt and it worked. Thank you!

1 Like