浮点格式冲突的数据框
Dataframe with conflicting float formatting
我有以下数据框:
pd.DataFrame({'Full Dataset': m1_baseline.params,
'Train Set': m1_train.params})
产生以下 table:
Full Dataset Train Set
Intercept 6.078966e+01 62.479667
DISTANCE 4.418002e-03 0.001389
AP_TOTAL_ARRIVALS -8.944526e-07 -0.000006
AL_TOTAL_FLIGHTS -7.643211e-06 -0.000008
Lunch -4.391630e+00 -5.179138
显然第一列而不是第二列使用科学记数法令人困惑。
有办法解决这个问题吗?
你可以试试df.style:
df.style.format('{:.2f}')
此填充的数字最多保留 2 位小数,您可以更改数字以更改您想要的小数位数
我有以下数据框:
pd.DataFrame({'Full Dataset': m1_baseline.params,
'Train Set': m1_train.params})
产生以下 table:
Full Dataset Train Set
Intercept 6.078966e+01 62.479667
DISTANCE 4.418002e-03 0.001389
AP_TOTAL_ARRIVALS -8.944526e-07 -0.000006
AL_TOTAL_FLIGHTS -7.643211e-06 -0.000008
Lunch -4.391630e+00 -5.179138
显然第一列而不是第二列使用科学记数法令人困惑。
有办法解决这个问题吗?
你可以试试df.style:
df.style.format('{:.2f}')
此填充的数字最多保留 2 位小数,您可以更改数字以更改您想要的小数位数