【发布时间】:2026-01-30 13:30:01
【问题描述】:
在 Anaconda Python 2.7.12、Pandas 18.1、Windows Server 2012 上运行时:
df['z'] = df['y'].str.replace(' ', '').astype(int)
我收到此错误:
OverflowError: Python int too large to convert to C long
我在 MacOS 10.11 或 Ubuntu 14.04 上没有收到此错误。我从其他地方读到,Windows C++ 编译器对 long 的定义与类 Unix 操作系统不同。如果是这样,我该如何在 Windows 上进行这项工作?
此外,data.txt 的大小仅为 172 KB。如果有帮助,data.txt 会采用这种形式:
x|y
99999917|099999927 9991
99999911|999999979 9994
99999912|999999902 9992
【问题讨论】:
-
试试
.astype('int64')- 在 Windows 上int总是 32 位。 -
那行得通。将此作为答案,我会接受。
标签: python c++ pandas numpy anaconda