I have the following code that is currently displaying the group bar chart.
pd.crosstab(train_data['workclass'],train_data['income']).plot(kind="bar")
plt.xlabel('Workclass')
plt.ylabel('Income Count')
plt.suptitle("Training Data: Workclass vs Income", fontweight="bold")
My data looks like this:
The current chart looks like this:
I want to display the chart by sorting the orange section (income >50K) in descending order. So the tallest orange bar should be on the left side. How do I do that?
Update I tried the following codes and get the following error.
CT = pd.crosstab(train_data['education'],train_data['income'])
CT.sort_values(train_data['income'], ascending=False).plot(kind='bar')
plt.xlabel('Education')
plt.ylabel('Income Count')
plt.suptitle("Training Data: Education vs Income", fontweight="bold")


