MemoryError: Unable to allocate array with shape (118, 840983) and data type float64

北城以北 提交于 2021-02-10 14:21:10

问题


I'm getting the following error:

MemoryError: Unable to allocate array with shape (118, 840983) and data type float64

in my python code whenever I am running a python pandas.readcsv() function to read a text file. Why is this??

This is my code:

import pandas as pd
df = pd.read_csv("LANGEVIN_DATA.txt", delim_whitespace=True)

回答1:


The MemoryError means, you file is too large to readcsv in one time, you need used the chunksize to avoid the error.

just like:

import pandas as pd
df = pd.read_csv("LANGEVIN_DATA.txt", delim_whitespace=True, chunksize=1000)

you can read the official document for more help.

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html



来源:https://stackoverflow.com/questions/58910947/memoryerror-unable-to-allocate-array-with-shape-118-840983-and-data-type-flo

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!