Python 如何在pandas'中以不同颜色显示值;桌子?

Python 如何在pandas'中以不同颜色显示值;桌子?,python,pandas,pivot-table,Python,Pandas,Pivot Table,我试图从中重现 我的代码是: impute_grps = data.pivot_table(values=["Loan_Status"], index=[ "Credit_History","Gender"], aggfunc='count') print (impute_grps) impute_grps.plot(kind='bar', stacked=True, color=['red','blue'], grid=False) 给出下图。有人能告诉我如何按照原始状态分割贷款吗?我尝

我试图从中重现

我的代码是:

impute_grps = data.pivot_table(values=["Loan_Status"], index=[ "Credit_History","Gender"],  
aggfunc='count')
print (impute_grps)
impute_grps.plot(kind='bar', stacked=True, color=['red','blue'], grid=False)
给出下图。有人能告诉我如何按照原始状态分割贷款吗?我尝试将其添加到索引中,但得到
ValueError:Grouper表示“贷款状态”而不是一维的
error


我想您需要在共享链接中定义的某个地方使用交叉表。“temp3=pd.crosstab(df['Credit\u History',df['Loan\u Status'))”我想您需要在共享链接中定义的某个地方使用交叉表。“temp3=pd.交叉表(df['Credit\u History'],df['Loan\u Status'])”