我有一个由这个代码生成的数据帧:
hmdf = pd.DataFrame(hm01)
new_hm02 = hmdf[['FinancialYear','Month']]
new_hm01 = hmdf[['FinancialYear','Month','FirstReceivedDate']]
hm05 = new_hm01.pivot_table(index=['FinancialYear','Month'], aggfunc='count')
vals1 = ['April ', 'May ', 'June ', 'July ', 'August ', 'September', 'October ', 'November ', 'December ', 'January ', 'February ', 'March ']
df_hm = new_hm01.groupby(['Month', 'FinancialYear']).size().unstack(fill_value=0).rename(columns=lambda x: '{}'.format(x))
df_hml = df_hm.reindex(vals1)
然后我有一个函数来突出显示每列中的最大值:
^{pr2}$然后这个代码:dfPercent.style.apply(highlight_max)
生成了:
如您所见,只有第一列和最后一列高亮显示正确的“最大值”。在
有人知道出什么问题了吗?在
谢谢你
为了正确的
max
,您需要将值转换为float,因为get max value of strings-9
更像是1
:样本:
^{pr2}$相关问题 更多 >
编程相关推荐