2

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?

jdoe
6646 silver badges19 bronze badges
asked Oct 25, 2017 at 17:12
1
  • Probably the word length of the machine, as well as the range of the data elements. Commented Oct 25, 2017 at 17:12

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.