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.