I want to output a pandas dataframe to a json file in a specific way

Viewed 109

How do you set up a dictionary, so that you can insert information from a dataframe in a certain format?

1 Answers

You must use orient="records".

maindf.to_json(orient="records")

or

maindf.to_json(orient="columns")
Related