Python transform json – Stack Overflow in Spanish

I've been with a problem for several days that is killing me little by little.

The problem I have is that I need to convert (or transform) a json taking into account that it is grouped by a property (OPERATOR).

That is, if I have the following JSON.

[{
        "HEADER_DATE": "2019-03-01",
        "IMPORTE": 24537.377,
        "OP": "OP1",
        "OPERATOR": "OPERADOR1"
    },
    {
        "HEADER_DATE": "2018-12-01",
        "IMPORTE": 48831.8088,
        "OP": "OP1",
        "OPERATOR": "OPERADOR1"
    },
    {
        "HEADER_DATE": "2018-05-01",
        "IMPORTE": 536801.9383,
        "OP": "OP2",
        "OPERATOR": "OPERADOR2"
    },
    {
        "HEADER_DATE": "2018-05-01",
        "IMPORTE": 4283.5844,
        "OP": "OP3",
        "OPERATOR": "OPERADOR3"
    },
    {
        "HEADER_DATE": "2018-12-01",
        "IMPORTE": 4254.775,
        "OP": "OP3",
        "OPERATOR": "OPERADOR3"
    }
]

The expected result would have to be something like this.

[{
        "2019-03-01": 24537.377,
        "2018-12-01": 48831.8088,
        "OP": "OP1",
        "OPERATOR": "OPERADOR1"
    }, {
        "2018-05-01": 536801.9383,
        "OP": "OP2",
        "OPERATOR": "OPERADOR2"
    },
    {
        "2018-05-01": 4283.5844,
        "2018-12-01": 4254.775,
        "OP": "OP2",
        "OPERATOR": "OPERADOR3"
    }
]

That is, the key HEADER_DATE would be the key of the new json and its value would be the value of the key AMOUNT grouped by the operator.

Here is the code I was doing.

class Pivot (object):


    def __init __ (self, data):
        self.data = data


    def pivot (self, as_key = None, as_value = None):
        item = []
        last_operator = None
        ob = {}
        for x in self.data:
            if as_key in x and as_value in x:
                try:
                    ob[x[as_key]]= float (x[as_value])
                except:
                    ob[x[as_key]]= x[as_value]

                for key, val in x.items ():
                    if x[as_key]  in ob and key! = as_key and key! = as_value:
                        ob[key] = val
                if last_operator! = x["OPERATOR"]:
                    item.append (ob)
                    last_operator = x["OPERATOR"]

        return item

Ignore the parameters of the pivot method

Thanks for any help and I hope to have explained.