大数字的 astype(int) 溢出

Overflow for astype(int) with big number

我在python中有以下号码:

import pandas
x = pandas.Series(1508770848527.423339843750000)

当我使用 x.apply(np.floor) 时,我得到 1508770848527.0,但是当我应用 x.astype(int) 时,我得到 -2147483648。

如何防止这种溢出?我想将数字作为整数。

转换为int64:

print (x.astype('int64'))
0    1508770848527
dtype: int64

或赞评论

print (x.astype(np.int64))
0    1508770848527
dtype: int64