Converting Python Tuple, Lists, Dictionaries Containing Pandas Objects (series/dataframes) To Json
I know I can convert pandas object like Series, DataFrame to json as follows: series1 = pd.Series(np.random.randn(5), name='something') jsonSeries1 = series1.to_json() #{'0':0.0548
Solution 1:
call pd.DataFrame
on seriesmap
then use to_json
pd.DataFrame(seriesmap).to_json()
'{"key1":{"0":0.8513342674,"1":-1.3357052602,"2":0.2102391775,"3":-0.5957492995,"4":0.2356552588}}'
Solution 2:
So far, there is not a single utility that can serialize or de-serialize nested Python structures containing Pandas objects. Even PyArrow (developed by Google) cannot handle complex numbers. So if you want to use that, you need to write your own code.
I have recently developed a library (https://github.com/xuancong84/pandas-serializer) that can serialize/de-serialize almost everything in Python. You can try that and report to me what cannot be identically de-serialized. Thanks! -:)
Post a Comment for "Converting Python Tuple, Lists, Dictionaries Containing Pandas Objects (series/dataframes) To Json"