简体   繁体   中英

What determines the data type of a numpy array

I am working using Python (Windows 64 bit). I wrote the following script:

y = np.array[(4,5,6)]
z = np.array([y, y**2])
z.dtype

While I run the above code it returned the type 'int32', however the exact same code gave a value of 'int64' in Christopher Brooks Coursera course Introduction to Data Science in Python .

Why is this the case?

NumPy defaults to converting Python ints to numpy.int_ , a dtype that corresponds to C long . On Windows, C long is 32-bit even on a 64-bit machine. On Linux, C long would be 64-bit, so you'd get np.int64 .

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