I have the Pandas DataFrame below and need to convert it to json format with the df.columns wrapped in a Django model name and "fields" fieldname. See below example of how the json should look. How should I do this?
df:
+-----------------+---------+------+
| Artist | Title | Year |
+-----------------+---------+------+
| Michael Jackson | Beat it | 1988 |
| Britney Spears | Lucky | 2012 |
| Justin Bieber | Baby | 2006 |
+-----------------+---------+------+
Json file output:
[
{
"model": "profiles.track",
"fields": {
"artist": "Michael Jackson",
"title": "Beat it",
"year": "1988",
}
},
{
"model": "profiles.track",
"fields": {
"artist": "Britney Spears",
"title": "Lucky",
"year": "2012",
}
},
{
"model": "profiles.track",
"fields": {
"artist": "Justin Bieber",
"title": "Baby",
"year": "2006",
}
}
]
"profiles.track"?