根据pyspark中的条件在json列表中查找和

8dtrkrch  于 2021-05-27  发布在  Spark
关注(0)|答案(0)|浏览(175)

嵌套json示例:

{
    "accounts": {
        "1": [{
            "userId": "XXXXXXX",
            "accountId": "1",
            "externalId": "XXXXXXXXXX",
            "status": "x",
            "planId": "1",
            "investmentObjective": null,
            "vestedBalance": 50097.01,
            "payoutAction": "0",
            "payoutAmount": 0.0,
            "bacs": "xxx-xxxx-xxxx",
            "rkId": "xxx",
            "planOwnerId": "xxxx",
            "userExternalId": "xxxxxxx"
        }],
        "2": [{ 
            "userId": "XXXXXXX",
            "accountId": "2",
            "externalId": "XXXXXXXXXX",
            "status": "X",
            "planId": "1",
            "investmentObjective": "I",
            "vestedBalance": 00.0,
            "payoutAction": "0",
            "payoutAmount": 50097.01,
            "bacs": "xxx-xxxx-xxxx",
            "rkId": "xxx",
            "planOwnerId": "xxxxxx",
            "userExternalId": "xxxxxxx"

        }],
        "3": [{ 
            "userId": "XXXXXXX",
            "accountId": "3",
            "externalId": "XXXXXXXXXX",
            "status": "X",
            "planId": "1",
            "investmentObjective": "I",
            "vestedBalance": 00.0,
            "payoutAction": "0",
            "payoutAmount": 2100.00,
            "bacs": "xxx-xxxx-xxxx",
            "rkId": "xxx",
            "planOwnerId": "xxxxxx",
            "userExternalId": "xxxxxxx"

        }]
    }
}

我需要在下面的条件下计算“sumpayoutamount”
“SumPayotAmount”:investmentobjective=“i”的账户总和(PayotAmount)
上例:“sumpayoutamount”:50097.01+2100.00 for investmentobjective=“i”
如何在Pypark中实现这一点?谢谢

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题