I have a dataframe that gets manipulated a few times. The end result is a data frame that looks like this:
Company volume
1 NV 14
2 GD 8
3 AB 6
I covert this dataframe into json format like so:
formattedDF.to_json(orient='columns')
However, I get something like this:
'{"company":{"1":"NV","2":"GD","3":"AB"},"volume":{"1":14,"2":8,"3":6}}'
Which is very close to what I want, but the format I'm looking for is:
'{"company": ["NV", "GD","AB"], "volume":[14, 8, 6}]'
Where the keys give the values in array format instead. How can I achieve this?