如何在Pandas透视表中以不同颜色显示数值?

2024-03-29 13:09:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试从here重新创建this graph

我的代码是:

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 for 'Loan_Status' not 1-dimensional错误

enter image description here


Tags: 代码dataindexherestatustablethishistory