Why i'm getting an error?

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

So, i’m trying to plot and wrote this

My Code:

wnba = pd.read_csv('wnba.csv')

pts_sample = []
for lap in range(100):
    sample = wnba['PTS'].sample(n=10, random_state=lap)
plt.scatter(range(1,101), pst_sample)

What I expected to happen: I expected a scatter plot and it should print a scatter plot

What actually happened:

ValueError: x and y must be the same size

But the interesting thing is that after reading my code multiple times and trying to find an error i checked the answer and to be honest i don’t find any difference between my code and the answer code. So why i’m getting an error?

Answer code:

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)

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

Hi @alegiraldo666, I run your code and the error result from the following 2 lines: change pst_sample argument to the plt.scatter() function to pts_sample and the code runs.


plt.scatter(range(1,101), pst_sample)



Because you have a typo in your code -

plt.scatter(range(1,101), pst_sample)

Above you are passing the variable pST_sample, instead of pTS_sample.

You might have a pST_sample variable defined elsewhere in your code too, that’s why you get that error. Otherwise you would have gotten an error corresponding to that typo.


@enext7771 @the_doctor Thank you both! i didn’t saw that typo. However is still weird because i didn’t had a pst_sample variable