简体   繁体   English

Python MemoryError:无法为形状为 () 且数据类型为 int64 的数组分配 10.8 TiB

[英]Python MemoryError: Unable to allocate 10.8 TiB for an array with shape () and data type int64

I am trying to combine two data sets.我正在尝试合并两个数据集。 Using codes as follows使用代码如下

pd1=pd.read_csv('path1')  # 1456472 rows x 17 columns
pd2=pd.read_csv('path2')  # 1083899 rows x 42 columns
pd=pd.merge(left=pd1,right=pd2,how='left',on='id')

It returns with error:它返回错误:

MemoryError: Unable to allocate 10.8 TiB for an array with shape (1483050607760,) and data type int64 MemoryError:无法为形状为 (1483050607760,) 且数据类型为 int64 的数组分配 10.8 TiB

How can I solve this if my laptop is a 500GB+8GB one?如果我的笔记本电脑是 500GB+8GB,我该如何解决这个问题? Thank you in advance.先感谢您。

try dask then you can convert it to pandas if you want to on other machine尝试 dask 然后你可以将它转换为熊猫,如果你想在其他机器上

import dask.dataframe as dd

#pip install "dask[dataframe]"

dd1=dd.read_csv('path1') 
dd2=dd.read_csv('path2')  
dd=dd.merge(left=dd1,right=dd2,how='left',on='id')

Use this new way to convert sparse matrix directly to dataframe:使用这种新方法将稀疏矩阵直接转换为 dataframe:

df = pd.DataFrame.sparse.from_spmatrix(vectorized_text)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python - MemoryError: 无法为 int64 类型的数组分配 - Python - MemoryError: Unable to allocate for an array with type int64 MemoryError:无法为形状为 (5844379795,) 且数据类型为 int64 的数组分配 43.5 GiB - MemoryError: Unable to allocate 43.5 GiB for an array with shape (5844379795,) and data type int64 无法为形状为 (27939587241,) 且数据类型为 int64 的数组分配 208.GiB? - Unable to allocate 208. GiB for an array with shape (27939587241,) and data type int64? MemoryError: Unable to allocate 617. GiB for an array with shape (82754714206,) and data type float64 On Windows and using Python - MemoryError: Unable to allocate 617. GiB for an array with shape (82754714206,) and data type float64 On Windows and using Python MemoryError: 无法分配形状 (118, 840983) 和数据类型 float64 的数组 - MemoryError: Unable to allocate array with shape (118, 840983) and data type float64 MemoryError: Unable to allocate 115. GiB for an array with shape (1122, 1122, 12288) and data type float64 - MemoryError: Unable to allocate 115. GiB for an array with shape (1122, 1122, 12288) and data type float64 MemoryError: Unable to allocate 797. MiB for an array with shape (51, 51, 40169) and data type float64 - MemoryError: Unable to allocate 797. MiB for an array with shape (51, 51, 40169) and data type float64 MemoryError: 无法分配形状为 (200, 20, 244, 244, 3) 和数据类型为 float64 的数组 - MemoryError: Unable to allocate array with shape (200, 20, 244, 244, 3) and data type float64 MemoryError:无法为形状为 (323313, 3435) 且数据类型为 float64 的数组分配 8.27 GiB - MemoryError: Unable to allocate 8.27 GiB for an array with shape (323313, 3435) and data type float64 MemoryError:无法为形状为 (28709, 224, 224, 3) 且数据类型为 float64 的数组分配 32.2 GiB - MemoryError: Unable to allocate 32.2 GiB for an array with shape (28709, 224, 224, 3) and data type float64
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM