Relative Content

Tag Archive for pythonjsonpandasgroup-by

python DataFrame groupby convert NaN to None to generate a valid json

I get several jsons which I have to transform and join, what I do with pandas and afterwards I have to generate a json as well.
the structure of the final json is fixed.
sometimes some fields in the jsons are missing (which is correct) but I have to keep the fields in the joined object wich also works fine.
I have to convert all NaN values to None to get afterwards a valid json with null values but after the groupby operation it converts some None values back to NaN.
See the example attached: