[英]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.