这对我有帮助:
merged.style.set_precision(2).background_gradient(cmap = 'Blues')
Nan
,则其数据类型为float
,笔记本将使用逗号显示数据(即使第一个小数为零)。我建议的解决方案是将这些列的数据类型转换为'Int32'
或'Int64'
(int
会引发错误)。for col in data.columns:
if data[col].dtype == 'float64':
data[col].astype('Int32')
Styler.format(precision=..)
。 - mrp