matplotlib: plot multiple columns of pandas data frame on the bar chart

后端 未结 2 701
故里飘歌
故里飘歌 2020-12-07 16:33

I am using the following code to plot a bar-chart:

import matplotlib.pyplot as pls 
my_df.plot(x=\'my_timestampe\', y=\'col_A\', kind=\'bar\') 
plt.show()
         


        
2条回答
  •  一生所求
    2020-12-07 17:00

    Although the accepted answer works fine, since v0.21.0rc1 it gives a warning

    UserWarning: Pandas doesn't allow columns to be created via a new attribute name

    Instead, one can do

    df[["X", "A", "B", "C"]].plot(x="X", kind="bar")
    

提交回复
热议问题