0

I am a beginner, and have written the following code:

wn=np.random.normal(loc=raw_data.Quantity.mean(), scale=raw_data.Quantity.std(), size=len(training_data))
training_data['wn']=wn
 training_data.wn.plot(figsize=(20,5), title="LOL")
plt.title('White Noise')
plt.ylim(0,2400)
plt.show()     

It gives the following error:

AttributeError: 'numpy.ndarray' object has no attribute 'plot'

Following are the values for the White Noise:

In[140]:wn
Out[140]: array([313.12254531, 43.56086818, 298.21441411, ..., -50.96308586, 193.43057718, 242.80841993])

Can anyone please help me with this?

2 Answers2

0

Instead of calling the plot method on the array itself, try running

plt.plot(wn)
ValeKnappich
  • 162
  • 1
  • 8
0

The error you describe is because you are trying to get numpy to produce the plot (numpy does not do plotting), whereas it looks like you want to use matplotlib for your plotting.

Replace training_data.wn.plot(figsize=(20,5), title="LOL") with plt.plot(wn,'.') and this will plot each point.

Without more informaiton its difficult to be more specific with the plot. Thie above will plot each point in turn and increment along the x-axis with each point (i.e. if there are 1000 points the x-axis will run from 0-999 with 1 point plotted at each.

MattB
  • 520
  • 3
  • 12