0

I've a pandas DataFrame with Multi-Level index of 4 levels (say Name, Year, Month, Date) and i want to make a nested JSON from this DataFrame which has 2 columns namely, col1 & col2, with arbitrary numbers.

I've tried df.to_json() with different 'orient' values but it doesn't give json in required nested structure.

The structure of the nested JSON should be like: 'Name' within should be 'Year' within which should be 'Month' within which should be 'Date' and then the column values in a list or dictionary. So, for the key of 'Year' we will have 12 months objects, and so on.

Ravikant Singh
  • 338
  • 5
  • 18
  • 1
    Hello and welcome on Stack Overflow. Please give a [minimal example](https://stackoverflow.com/help/minimal-reproducible-example) showing what you have tried. – Bertrand Gazanion Jun 19 '19 at 14:03
  • See how to make a good pandas question: https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples – Valentino Jun 19 '19 at 16:52

0 Answers0