These are chat archives for numpy/numpy
I tried to serialize numpy.int64, I googled it and found many results describing the same issue, but I did not understand if this was bug or not
import json import numpy as np print('numpy', np.__version__) # numpy 1.11.0 arr_float64 = np.array([1., 2., 3.]) arr_int64 = np.array([1, 2, 3]) json.dumps(list(arr_float64)) json.dumps(list(arr_int64))
In the script above the second dumps fails, could someone help me to understand this issue? thanks in advance
In : import inspect as ins In : ins.getmro(np.int64) Out: (numpy.int64, numpy.signedinteger, numpy.integer, numpy.number, numpy.generic, object) In : ins.getmro(np.float64) Out: (numpy.float64, numpy.floating, numpy.inexact, numpy.number, numpy.generic, float, object)
float64you can see
floatas one of its bases.
.tolist()on it or to implement a JSON encoder - depending on what is simpler/more performant in your particular case.