-2

I have a panda dataframe df. It looks something like this;

   Name     Date      Attr1      Attr1      Attr2     Sales
    Joe  26-12-2007  1.000000  1.000000  1.000000     52214
    Joe  27-12-2007  0.975380  0.983405  0.960474     78870
    Joe  28-12-2007  0.959963  0.962608  0.953732     65745
    Joe  31-12-2007  0.940175  0.979434  0.951174     83813

I want to plot Attr1 column. Here is my python code.

import matplotlib.pyplot as plt
df['Attr1'].plot(figsize=(16, 12))
plt.legend()

No plot appears after running the code. What is wrong with it? I am open to new code to plot Attr1 data.

I am using python v3.6

user1315789
  • 3,069
  • 6
  • 18
  • 41

2 Answers2

3

You created a instance of plot and assigned something to it in your code. When you do that it is only created that object, now for rendering it you need to enter command that renders, which is

plt.show()

It should be like below:

import matplotlib.pyplot as plt
df['Attr1'].plot(figsize=(16, 12))
plt.legend()
plt.show()
Tilak Putta
  • 758
  • 4
  • 18
2

I think you should just add:

plt.show()

after your code

Joe
  • 12,057
  • 5
  • 39
  • 55