1
我有一个pandas.DataFrame
和numpy.ndarray
s条目(不同大小)。我如何将它序列化为json?JSON - 使用numpy数组条目序列化大熊猫数据框
看来,大熊猫不支持ndarrays的序列化的时刻:
pandas.DataFrame([{'a': numpy.array(1)}, {'a': numpy.array((1,2))}]).to_json()
TypeError: array(1) (0d array) is not JSON serializable at the moment
密切相关的问题,其答案将不解决我的问题:
Storing Dataframe with Array Entries:我不能在那里使用好的技巧,因为我的数据框由不同大小的数组组成。
Convert numpy type to python:如果DataFrame.to_json()
没错,但我真的喜欢JSON,因为它是最可读的序列化,我知道。 我现在更新了我的问题,具体关于json。谢谢 – nivniv