简体   繁体   中英

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. But when I ran the same code on the python console using the command prompt it gave a memory error. Why so?

I am running the following line 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. I tested your code with my PC it works fine with vscode, jupyter and cmd. Try this code:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM