python - pandas内存错误

 闺蜜好我会明白 发布于 2022-11-05 13:06
  File "D:\WinPython-32bit-2.7.9.3\python-2.7.9\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 680, in runfile
    execfile(filename, namespace)

  File "D:\WinPython-32bit-2.7.9.3\python-2.7.9\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 71, in execfile
    exec(compile(scripttext, filename, 'exec'), glob, loc)

  File "D:/pywork/Marking/DataProcessing.py", line 113, in 
    df = pd.DataFrame(data, columns=colNames)

  File "D:\WinPython-32bit-2.7.9.3\python-2.7.9\lib\site-packages\pandas\core\frame.py", line 258, in __init__
    dtype=dtype)

  File "D:\WinPython-32bit-2.7.9.3\python-2.7.9\lib\site-packages\pandas\core\frame.py", line 4627, in _arrays_to_mgr
    return create_block_manager_from_arrays(arrays, arr_names, axes)

  File "D:\WinPython-32bit-2.7.9.3\python-2.7.9\lib\site-packages\pandas\core\internals.py", line 3539, in create_block_manager_from_arrays
    blocks = form_blocks(arrays, names, axes)

  File "D:\WinPython-32bit-2.7.9.3\python-2.7.9\lib\site-packages\pandas\core\internals.py", line 3614, in form_blocks
    int_blocks = _multi_blockify(int_items)

  File "D:\WinPython-32bit-2.7.9.3\python-2.7.9\lib\site-packages\pandas\core\internals.py", line 3681, in _multi_blockify
    list(tup_block), dtype)

  File "D:\WinPython-32bit-2.7.9.3\python-2.7.9\lib\site-packages\pandas\core\internals.py", line 3725, in _stack_arrays
    stacked = np.empty(shape, dtype=dtype)

MemoryError

使用pandas.DataFrame读175MB数据(111W行 X 38列),程序执行过程中报如上错误。

1 个回答
  • 是读入错误还是计算中错误?
    如果是后者,可以试试读入后 del 一些无用的 col,再计算
    百万行我试过,但这么多列没试过

    2022-11-12 01:52 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有