Create json files from dataframe

I have a dataframe with 10 rows like this:

id name team
1 Employee1 Team1
2 Employee2 Team2

How can I generate 10 json files from the dataframe with python? Here is the format of each json file:

{ "Company": "Company", "id": "1", "name": "Employee1", "team": "Team1" }

  • The field "Company": "Company" is the same in all json files.

  • Name of each json file is the name of each employee (i.e Employee1.json)

Read more here:

Content Attribution

This content was originally published by Harper at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: