0
非常に長い整数を含むデータフレームを作成しようとしています。次のように私のコードは次のとおりです。長すぎる整数のデータフレームを作成する
import pandas as pd
data = [123456789123456789123456789123456789123456789,
123456789123456789123456789123456789123456789]
cols = ['Col1', 'Col2']
df = pd.DataFrame(data, columns=cols)
print(df)
をしかし、私は次のエラーを取得しています:
Traceback (most recent call last):
File "/home/watson/Desktop/test.py", line 5, in <module>
df = pd.DataFrame(data, columns=cols)
File "/usr/local/lib/python2.7/dist-packages/pandas/core/frame.py",
line 330, in __init__
copy=copy)
File "/usr/local/lib/python2.7/dist-packages/pandas/core/frame.py",
line 463, in _init_ndarray
values = _prep_ndarray(values, copy=copy)
File "/usr/local/lib/python2.7/dist-packages/pandas/core/frame.py",
line 5578, in _prep_ndarray
values = convert(values)
File "/usr/local/lib/python2.7/dist-packages/pandas/core/frame.py",
line 5567, in convert
return maybe_convert_platform(v)
File "/usr/local/lib/python2.7/dist-
packages/pandas/core/dtypes/cast.py", line 47, in
maybe_convert_platform
values = lib.maybe_convert_objects(values)
File "pandas/_libs/src/inference.pyx", line 1165, in
pandas._libs.lib.maybe_convert_objects (pandas/_libs/lib.c:58498)
OverflowError: long int too large to convert
https://stackoverflow.com/questions/21591109/handling-huge-numbers-in-numpy-or-pandas – Wen