给定具有以下结构和值的数据框json_path-
| json_path | 报告组 | 实体/分组 |
|---|---|---|
| data.attributes.total.children.[0] | 基督徒家庭 | 亚伯拉罕家族 |
| data.attributes.total.children.[0].children.[0] | 基督徒家庭 | 在庄园 |
| data.attributes.total.children.[0].children.[0].children.[0].children.[0] | 基督徒家庭 | 现金 |
| data.attributes.total.children.[0].children.[0].children.[1].children.[0] | 基督徒家庭 | 投资级固定收益 |
我将如何过滤json_path包含children四次的行?即,我想过滤索引位置 2-3 -
| json_path | 报告组 | 实体/分组 |
|---|---|---|
| data.attributes.total.children.[0].children.[0].children.[0].children.[0] | 基督徒家庭 | 现金 |
| data.attributes.total.children.[0].children.[0].children.[1].children.[0] | 基督徒家庭 | 投资级固定收益 |
我知道如何获得部分匹配,但是方括号中的整数会不一致,所以我的直觉告诉我要以某种方式计算children(即children出现 4x)的实例并将其用作过滤的基础。
关于如何实现这一目标的任何建议或资源?