pd.describe(包括=[np.number]) return 0.00

pd.describe(include=[np.number]) return 0.00

我使用 df_30v.describe(include=[np.number]) 为我提供数据框中变量的摘要。但是结果是数字太多

count 235629.000000 235629.000000 235629.000000 119748.000000

我怎样才能得到下面的结果。谢谢!

count 235629.00 235629.00 235629.00 119748.00

致电pd.set_option('precision', 2):

In [165]: pd.set_option('precision', 2)
In [167]: df = pd.DataFrame(np.random.uniform(0, 10**6, size=(100,5)))
In [168]: df.describe()
Out[168]: 
               0          1          2          3          4
count     100.00     100.00     100.00     100.00     100.00
mean   440786.89  526477.58  457295.14  498070.00  481541.09
std    286118.94  264010.57  312539.39  310191.95  274682.03
min       677.71   11862.05    2934.92   13031.54   11728.73
25%    244739.83  316760.73  188148.99  207720.23  222285.78
50%    411391.98  527119.36  406672.95  496606.54  476422.05
75%    637488.49  741362.83  745412.65  778365.74  701966.74
max    993927.91  990323.15  998025.25  999628.94  998598.52

或者,临时更改一段代码的精度,use a context manager:

with pd.option_context('precision', 2):
    df = pd.DataFrame(np.random.uniform(0, 10**6, size=(100,5)))
    print(df.describe())