pandas 我希望绘制一个df.mean()的输出

hrirmatl  于 2023-06-28  发布在  其他
关注(0)|答案(2)|浏览(150)

请告诉我如何绘制列的平均值的输出。enter image description here

piv4azn7

piv4azn71#

绘制df.mean()import matplotlib as plt的图形,然后执行df.mean().plot(kind='bar')

c0vxltue

c0vxltue2#

import pandas as pd
import matplotlib.pyplot as plt

data = {
    'Store': ['storeA', 'storeB', 'storeC', 'storeD', 'storeE'],
    'Mean': [5865.480, 6756.710, 4942.105, 5431.405, 2580.025]
}

df = pd.DataFrame(data)

# plot df
df.plot(kind='bar', x='Store', y='Mean', color='red', xlabel='Store', ylabel='Value')

plt.show()

相关问题