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?
asked Oct 25, 2017 at 17:12
Abin John Thomas
1693 silver badges14 bronze badges
-
Probably the word length of the machine, as well as the range of the data elements.willeM_ Van Onsem– willeM_ Van Onsem2017年10月25日 17:12:54 +00:00Commented Oct 25, 2017 at 17:12
1 Answer 1
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.
answered Oct 25, 2017 at 17:16
user2357112
286k32 gold badges492 silver badges573 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-py