Issue
Given a variable in python of type int
, e.g.
z = 50
type(z)
## outputs <class 'int'>
is there a straightforward way to convert this variable into numpy.int64
?
It appears one would have to convert this variable into a numpy array, and then convert this into int64. That feels quite convoluted.
https://docs.scipy.org/doc/numpy-1.13.0/user/basics.types.html
Solution
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.
Answered By - user2357112
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.