I tried to replicate the example found on this website: http://mpld3.github.io/examples/scatter_tooltip.html
But I get the following error: Object of type \'nd
There is an open issue raised against this error, the link is https://github.com/mpld3/mpld3/pull/435
One work-around is to edit the mpld3/_display.py
file inside your mpld3 module, the edit will be on below default
function
before:
def default(self, obj):
if isinstance(obj, (numpy.int_, numpy.intc, numpy.intp, numpy.int8,
numpy.int16, numpy.int32, numpy.int64, numpy.uint8,
numpy.uint16,numpy.uint32, numpy.uint64)):
return int(obj)
elif isinstance(obj, (numpy.float_, numpy.float16, numpy.float32,
numpy.float64)):
return float(obj)
return json.JSONEncoder.default(self, obj)
after:
def default(self, obj):
if isinstance(obj, (numpy.int_, numpy.intc, numpy.intp, numpy.int8,
numpy.int16, numpy.int32, numpy.int64, numpy.uint8,
numpy.uint16,numpy.uint32, numpy.uint64)):
return int(obj)
elif isinstance(obj, (numpy.float_, numpy.float16, numpy.float32,
numpy.float64)):
return float(obj)
elif isinstance(obj, (numpy.ndarray,)): # add this line
return obj.tolist() # add this line
return json.JSONEncoder.default(self, obj)
basically you just added
elif isinstance(obj, (numpy.ndarray,)): # add this line
return obj.tolist() # add this line