How to convert python int into numpy.int64? How to convert python int into numpy.int64? numpy numpy

How to convert python int into numpy.int64?


z_as_int64 = numpy.int64(z)

It's that simple. Make sure you have a good reason, though - there are a few good reasons to do this, but most of the time, you can just use a regular int directly.


import numpy as npz = 3z = np.dtype('int64').type(z)print(type(z))

outputs:

<class 'numpy.int64'>

But i support Juliens question in his comment.