pandas dataframe.describe() 抑制科学记数法
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40347689/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
dataframe.describe() suppress scientific notation
提问by mfabi
How do I suppress scientific notation output from dataframe.describe():
如何抑制 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
My data is of type float64:
我的数据是 float64 类型的:
contrib_df["AMNT"].dtypes
dtype('float64')
回答by Ash Upadhyay
contrib_df["AMNT"].describe().apply(lambda x: format(x, 'f'))
As the function describe returns a dataframe, what the above function does is, it simply formats each row to the regular format. I wrote this answer because I was having a though in my mind, that was Its pointless to get count of 95 as 95.00000e+01Also in our regular format its easier to compare.
由于函数 describe 返回一个数据帧,上面的函数所做的是,它只是将每一行格式化为常规格式。我写这个答案是因为我有一个想法,那就是 将 95 计数为 95.00000e+01 毫无意义,而且在我们的常规格式中,它更容易比较。
Before applying the above function we were getting
在应用上述函数之前,我们得到
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
After applying, we get
申请后,我们得到
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