pandas mean 返回 inf

In [12]: np.finfo(np.float16).max
Out[12]: 65500.0

In [15]: df['a']=np.array([656]*100)
In [16]: df['a'].sum()
Out[16]: 65600

In [20]: df['a'] = df['a'].astype(np.float16)

In [21]: df['a'].sum() # 当sum的值大于np.float16的最大范围时就返回inf,后面mean,std等都返回inf
Out[21]: inf

In [22]: df['a'].mean()
Out[22]: inf

posted on 2019-02-19 21:23  Frank_Allen  阅读(1047)  评论(0编辑  收藏  举报

导航