mfa*_*abi 23 python dataframe pandas
如何抑制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
Run Code Online (Sandbox Code Playgroud)
我的数据类型为float64:
contrib_df["AMNT"].dtypes
dtype('float64')
Run Code Online (Sandbox Code Playgroud)
Ash*_*yay 38
contrib_df["AMNT"]).describe().apply(lambda x: format(x, 'f'))
Run Code Online (Sandbox Code Playgroud)
由于函数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
Run Code Online (Sandbox Code Playgroud)
申请后,我们得到
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
Run Code Online (Sandbox Code Playgroud)
如果有帮助就打起来:)
归档时间: |
|
查看次数: |
12634 次 |
最近记录: |