如何从describe()函数在Python中打印整数?

如何从describe()函数在Python中打印整数?,第1张

如何从describe()函数在Python中打印整数

假设您具有以下条件

Dataframe

编辑

我检查了文档,您可能应该使用

pandas.set_option
API来做到这一点

In [13]: dfOut[13]:    a  b  c0  4.405544e+08  1.425305e+08  6.387200e+081  8.792502e+08  7.135909e+08  4.652605e+072  5.074937e+08  3.008761e+08  1.781351e+083  1.188494e+07  7.926714e+08  9.485948e+084  6.071372e+08  3.236949e+08  4.464244e+085  1.744240e+08  4.062852e+08  4.456160e+086  7.622656e+07  9.790510e+08  7.587101e+087  8.762620e+08  1.298574e+08  4.487193e+088  6.262644e+08  4.648143e+08  5.947500e+089  5.951188e+08  9.744804e+08  8.572475e+08In [14]: pd.set_option('float_format', '{:f}'.format)In [15]: dfOut[15]:       a     b     c0 440554429.333866 142530512.999182 638719977.8249651 879250168.522411 713590875.479215  46526045.8194872 507493741.709532 300876106.387427 178135140.5835413  11884941.851962 792671390.499431 948594814.8166474 607137206.305609 323694879.619369 446424361.5220715 174424035.448168 406285189.907148 445616045.7541376  76226556.685384 979050957.963583 758710090.1278677 876261954.607558 129857447.076183 448719292.4535098 626264394.999419 464814260.796770 594750038.7475959 595118819.308896 974480400.272515 857247528.610996In [16]: df.describe()Out[16]:a     b     ccount        10.000000        10.000000        10.000000mean  479461624.877280 522785202.100082 536344333.626082std   306428177.277935 320806568.078629 284507176.411675min    11884941.851962 129857447.076183  46526045.81948725%   240956633.919592 306580799.695412 445818124.69612150%   551306280.509214 435549725.351959 521734665.60055275%   621482597.825966 772901261.744377 728712562.052142max   879250168.522411 979050957.963583 948594814.816647
编辑结束
In [7]: dfOut[7]:    a  b  c0  4.405544e+08  1.425305e+08  6.387200e+081  8.792502e+08  7.135909e+08  4.652605e+072  5.074937e+08  3.008761e+08  1.781351e+083  1.188494e+07  7.926714e+08  9.485948e+084  6.071372e+08  3.236949e+08  4.464244e+085  1.744240e+08  4.062852e+08  4.456160e+086  7.622656e+07  9.790510e+08  7.587101e+087  8.762620e+08  1.298574e+08  4.487193e+088  6.262644e+08  4.648143e+08  5.947500e+089  5.951188e+08  9.744804e+08  8.572475e+08In [8]: df.describe()Out[8]:        a  b  ccount  1.000000e+01  1.000000e+01  1.000000e+01mean   4.794616e+08  5.227852e+08  5.363443e+08std    3.064282e+08  3.208066e+08  2.845072e+08min    1.188494e+07  1.298574e+08  4.652605e+0725%    2.409566e+08  3.065808e+08  4.458181e+0850%    5.513063e+08  4.355497e+08  5.217347e+0875%    6.214826e+08  7.729013e+08  7.287126e+08max    8.792502e+08  9.790510e+08  9.485948e+08

您需要摆弄

pandas.options.display.float_format
属性。请注意,在我的代码中我使用了
import pandas aspd
。快速修复是这样的:

In [29]: pd.options.display.float_format = "{:.2f}".formatIn [10]: dfOut[10]:   a b c0 440554429.33 142530513.00 638719977.821 879250168.52 713590875.48  46526045.822 507493741.71 300876106.39 178135140.583  11884941.85 792671390.50 948594814.824 607137206.31 323694879.62 446424361.525 174424035.45 406285189.91 445616045.756  76226556.69 979050957.96 758710090.137 876261954.61 129857447.08 448719292.458 626264395.00 464814260.80 594750038.759 595118819.31 974480400.27 857247528.61In [11]: df.describe()Out[11]:       a b ccount        10.00        10.00        10.00mean  479461624.88 522785202.10 536344333.63std   306428177.28 320806568.08 284507176.41min    11884941.85 129857447.08  46526045.8225%   240956633.92 306580799.70 445818124.7050%   551306280.51 435549725.35 521734665.6075%   621482597.83 772901261.74 728712562.05max   879250168.52 979050957.96 948594814.82


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5674894.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存