Skip to content
Advertisement

How to convert dataframe column into list of lists json format?

My dataframe looks like below and I want to use sales column and convert it into json files for each month as a list of lists.

sales dt
156 2022-01
192 2022-01
147 2022-02
192 2022-02
JavaScript

Using this, I am getting this format of json files:

JavaScript

However, I want to have:

JavaScript

I have created this as a toy example. I want to implement this on a very large dataframe for several months data. Can anyone point me how to achieve this? Thank you.

Advertisement

Answer

You can try:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement