微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

python – dataframe.describe()压制科学记数法

参见英文答案 > Suppressing scientific notation in pandas?                                    3个
如何抑制dataframe.describe()的科学记数法输出

contrib_df["AMNT"].describe()

count    1.979680e+05
mean     5.915134e+02
std      1.379618e+04
min     -1.750000e+05
25%      4.000000e+01
50%      1.000000e+02
75%      2.500000e+02
max      3.000000e+06
Name: AMNT, dtype: float64

我的数据类型为float64:

contrib_df["AMNT"].dtypes

dtype('float64')

解决方法:

contrib_df["AMNT"]).describe().apply(lambda x: format(x, 'f'))

由于函数describe返回一个数据帧,上述函数的作用是,它只是将每一行格式化为常规格式.
 我写了这个答案,因为我心中有一个,但那是
毫无意义的计算95为95.00000e 01
同样在我们的常规格式中,它更容易比较.

在应用上述功能之前,我们得到了

count    9.500000e+01
mean     5.621943e+05
std      2.716369e+06
min      4.770000e+02
25%      2.118160e+05
50%      2.599960e+05
75%      3.121170e+05
max      2.670423e+07
Name: salary, dtype: float64

申请后,我们得到

count          95.000000
mean       562194.294737
std       2716369.154553
min           477.000000
25%        211816.000000
50%        259996.000000
75%        312117.000000
max      26704229.000000
Name: salary, dtype: object

如果有帮助就打起来:)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐