简体   繁体   English

无法在python控制台中分配形状和数据类型为int32的数组

[英]Unable to allocate array with shape and data type int32 in python console

I have been working with large datasets lately.我最近一直在处理大型数据集。 First I was working on jupyter notebook on a windows machine where I was creating an array with shape (30072, 15484) and data type int32 and it was able to create it successfully.首先,我在 Windows 机器上使用 jupyter notebook 工作,在那里我创建了一个形状为 (30072, 15484) 和数据类型为 int32 的数组,它能够成功创建它。 But when I ran the same code on the python console using the command prompt it gave a memory error.但是当我使用命令提示符在 python 控制台上运行相同的代码时,它给出了一个内存错误。 Why so?为什么这样?

I am running the following line pd.DataFrame(np.zeros((30000,15000),dtype=object))我正在运行以下行pd.DataFrame(np.zeros((30000,15000),dtype=object))

You are using your code with dtype=object which takes more time to create than a simple int32 type.您正在使用带有 dtype=object 的代码,这比简单的 int32 类型需要更多的时间来创建。 I tested your code with my PC it works fine with vscode, jupyter and cmd.我用我的电脑测试了你的代码,它在 vscode、jupyter 和 cmd 上运行良好。 Try this code:试试这个代码:

pd.DataFrame(np.zeros((30000,15000),dtype="int32"))

暂无
暂无

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

相关问题 MemoryError:无法为形状为 (5004, 96) 且数据类型为 int32 的数组分配 1.83 MiB - MemoryError: Unable to allocate 1.83 MiB for an array with shape (5004, 96) and data type int32 MemoryError:在python中使用word2vec时无法分配形状和数据类型为float32的数组 - MemoryError: unable to allocate array with shape and data type float32 while using word2vec in python Python MemoryError:无法为形状为 () 且数据类型为 int64 的数组分配 10.8 TiB - Python MemoryError: Unable to allocate 10.8 TiB for an array with shape () and data type int64 无法分配具有形状和数据类型的数组 - Unable to allocate array with shape and data type numpy.core._exceptions.MemoryError:无法为形状为 (1073741824, 0) 且数据类型为 float32 的数组分配 0 个字节 - numpy.core._exceptions.MemoryError: Unable to allocate 0 bytes for an array with shape (1073741824, 0) and data type float32 MemoryError: 无法分配形状为 (2515, 406272) 且数据类型为 float32 的数组 - MemoryError: Unable to allocate array with shape (2515, 406272) and data type float32 MemoryError: Unable to allocate 137. MiB for an array with shape (3000, 4000, 3) and data type float32 - MemoryError: Unable to allocate 137. MiB for an array with shape (3000, 4000, 3) and data type float32 无法为形状为 (129213603, 28) 且数据类型为 int8 的数组分配 3.37 GiB - Unable to allocate 3.37 GiB for an array with shape (129213603, 28) and data type int8 MemoryError:无法为形状为 (5844379795,) 且数据类型为 int64 的数组分配 43.5 GiB - MemoryError: Unable to allocate 43.5 GiB for an array with shape (5844379795,) and data type int64 MemoryError:无法为形状为 (15500, 2, 240, 240, 1) 且数据类型为 int16 的数组分配 3.33 GiB - MemoryError: Unable to allocate 3.33 GiB for an array with shape (15500, 2, 240, 240, 1) and data type int16
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM