有一个数据帧,但需要用python制作条形图

有一个数据帧,但需要用python制作条形图,python,Python,嗨,我有一个非常大的数据帧,下面是一个快照。我想计算不同工人类型的目标分割百分比,并绘制条形图(见附图) 试试看 试试这个: df.groupby('Worker type').count().plot.bar(y='TARGET') import matplotlib.pyplot as plt ax = df[['Worker type']].plot(kind='bar', title ="Worker Type", figsize=(15, 10), legend

嗨,我有一个非常大的数据帧,下面是一个快照。我想计算不同工人类型的目标分割百分比,并绘制条形图(见附图)

试试看

试试这个:

df.groupby('Worker type').count().plot.bar(y='TARGET')

import matplotlib.pyplot as plt
ax = df[['Worker type']].plot(kind='bar', title ="Worker Type", figsize=(15, 10), legend=True, fontsize=12)
ax.set_xlabel("Worker", fontsize=12)
ax.set_ylabel("Count", fontsize=12)
plt.show()
df.groupby('Worker type').count().plot.bar(y='TARGET')