skip to Main Content

Python format json for saving to file

My data looks like this: Key1: [Key2:[{},{},...{}]] The code something like this: dict_={} dict_['Key2']=all_items dict_fin={} dict_fin['Ke1']=[dict_] df=pd.DataFrame(dict_fin) df.to_json(filepath, orient="records",lines=True) I would like to have saved json like this: { "Key1": [{"Key2" : [{},{},...,{}]}] } Instead, I get it like this:…

VIEW QUESTION
Back To Top
Search