0

I have a pandas dataframe which im trying to convert into a nested Newline Delimited Json. I have already tried using Pandas Groupby function as seen in the following post Convert Pandas Dataframe to nested JSON but it doesn't allow me to make it as deep as i want to.

Tried some dictionary solutions i found like this one but it didn't help either.

Screenshot of the dataframe im working on

I would deeply appreciate any kind of help or tip given, to help me find the direction that i should follow.

The desired Json format

{
   year:2010{
    
        "capacity":[
            
                "Κρεβατια"(beds):{
                        "1*" = "###",
                        "2*" = "###",
                        "3*" = "###",
                        "4*" = "###",
                        "5*" = "###"
                    },
                {
                "Δωματια"(Rooms):{
                    
                        "1*" = "###",
                        "2*" = "###",
                        "3*" = "###",
                        "4*" = "###",
                        "5*" = "###"
                
                }},
                {
                "Μοναδες"(Units):{
                    
                        "1*" = "###",
                        "2*" = "###",
                        "3*" = "###",
                        "4*" = "###",
                        "5*" = "###"
                
                    }
            
                }
           }
    municipality:"ΠΕΙΡΑΙΩΣ":[{
            "occupancyRate"="###"

            source:"αλλοδαπων":{
                     "overnightStays"="###"
                     "departures"="###"
            },{
            source:"ημεδαπων":{
                     "overnightStays"="###"
                     "departures"="###"
            
            },{
    municipality:"ΑΓΙΟΥ ΙΩΑΝΝΗ ΡΕΝΤΗ":[{
            "occupancyRate"="###"

            source:"αλλοδαπων":{
                      "overnightStays"="###"
                      "departures"="###"
            },{
            source:"ημεδαπων":{
                      "overnightStays"="###"
                      "departures"="###"
            
        }
}

0 Answers0