python引入了一种新的数据类型'Int64',即可完美解决此问题
1、python中有6种标准数据类型: number(数字),string (字符串),list (列表),tuple(元组),set (集合),dictionary (字典)。
2、type(),dtype(),astype()的区别。
用numpy读入数据,默认的dtype是‘float64’,要转变numpy中数据的类型,不能直接改变原数据的dtype,只能用astype()。
float类型包括‘float64’,‘float32’和‘float16’,默认为'float64'。
int 类型包括‘int64’,‘int32’,‘int16’和‘int8’,默认为‘int64’。
python中的字典转json时,报该错。经过对字典的数据进行debug发现,字典中的value对应的类型是numpy.int64, 正常情况下应该是numpy.float64。因此手动将int类型转化为float即可。