【发布时间】:2017-10-04 19:25:43
【问题描述】:
我只运行以下三行:
df = pd.read_hdf('data.h5')
print(df.mean())
print(df['derived_3'].mean())
第一个 print 列出了每一列的所有单独的手段,其中一个是
derived_3 -5.046012e-01
第二个print 仅给出此列的平均值并给出结果
-0.504715
尽管使用科学记数法和不使用科学记数法有所不同,但这些值不同 - 为什么会这样?
使用其他方法的示例
对sum() 执行相同的操作会导致以下结果:
derived_3 -7.878262e+05
-788004.0
同样,结果略有不同,但 count() 返回相同的结果:
derived_3 1561285
1561285
还有df.head()的结果:
id timestamp derived_0 derived_1 derived_2 derived_3 derived_4 \
0 10 0 0.370326 -0.006316 0.222831 -0.213030 0.729277
1 11 0 0.014765 -0.038064 -0.017425 0.320652 -0.034134
2 12 0 -0.010622 -0.050577 3.379575 -0.157525 -0.068550
3 25 0 NaN NaN NaN NaN NaN
4 26 0 0.176693 -0.025284 -0.057680 0.015100 0.180894
fundamental_0 fundamental_1 fundamental_2 ... technical_36 \
0 -0.335633 0.113292 1.621238 ... 0.775208
1 0.004413 0.114285 -0.210185 ... 0.025590
2 -0.155937 1.219439 -0.764516 ... 0.151881
3 0.178495 NaN -0.007262 ... 1.035936
4 0.139445 -0.125687 -0.018707 ... 0.630232
technical_37 technical_38 technical_39 technical_40 technical_41 \
0 NaN NaN NaN -0.414776 NaN
1 NaN NaN NaN -0.273607 NaN
2 NaN NaN NaN -0.175710 NaN
3 NaN NaN NaN -0.211506 NaN
4 NaN NaN NaN -0.001957 NaN
technical_42 technical_43 technical_44 y
0 NaN -2.0 NaN -0.011753
1 NaN -2.0 NaN -0.001240
2 NaN -2.0 NaN -0.020940
3 NaN -2.0 NaN -0.015959
4 NaN 0.0 NaN -0.007338
【问题讨论】:
-
另外,添加
df.dtypes? -
已添加到我的帖子中。这是一个非常大的文件,据我所知,其中一些数字有大约 20 位小数,这在 pandas 的结果中显示。这会以某种方式导致问题吗?