用户警告:此模式被解释为正则表达式,并且具有匹配组
给定以下 pandas DataFrame -
json_path | 报告组 | 实体/分组 | 实体 ID | 调整值(今天,无 Div,美元) | 调整后的 TWR(本季度,无 Div,美元) | 调整后的 TWR(年初至今,无 Div,美元) | 年化调整后的 TWR(自成立以来,无 Div,美元) | 调整值(无 Div,美元) | TWR 审计说明 |
---|---|---|---|---|---|---|---|---|---|
data.attributes.total.children。[0 ].孩子们。[0].孩子们。[0] | 巴拉克家族 | 威廉和鲁珀特信托 | 9957007 | -1.44 | -1.44 | ||||
data.attributes.total.children.[0].children.[0].children.[0].children.[0] | 兵营家庭 | 现金 | - | -1.44 | -1.44 | ||||
data.attributes.total.children.[0].children.[0].children.[1] | Barrack Family | Gratia Holdings No. 2 LLC | 8413655 | 55491732.66 | -0.971018847 | -0.971018847 | 11.52490309 | 55491732.66 | |
data.attributes.total.children.[0].children.[0].children.[1].children.[0] | Barrack Family | 投资级固定收益 | - | 18469768.6 | 18469768.6 | ||||
data.attributes.total.children.[0].children.[0].children.[1].children.[1] | Barrack Family | 高收益固定收益 | - | 3668982.44 | -0.205356545 | -0.205356545 | 4.441190127 | 3668982.44 |
我尝试使用以下语句仅保存包含 4 次 .children.[]
出现的行 -
代码: perf_by_entity_df = df[df['json_path'].str.contains(r'(\.children\.\[\d+\]){4}')]
但是收到以下内容:
错误:用户警告:此模式被解释为正则表达式,并且具有匹配组。要实际获取组,请使用 str.extract。
对于为什么会发生这种情况有什么建议吗?
Given the following pandas DataFrame -
json_path | Reporting Group | Entity/Grouping | Entity ID | Adjusted Value (Today, No Div, USD) | Adjusted TWR (Current Quarter, No Div, USD) | Adjusted TWR (YTD, No Div, USD) | Annualized Adjusted TWR (Since Inception, No Div, USD) | Adjusted Value (No Div, USD) | TWR Audit Note |
---|---|---|---|---|---|---|---|---|---|
data.attributes.total.children.[0].children.[0].children.[0] | Barrack Family | William and Rupert Trust | 9957007 | -1.44 | -1.44 | ||||
data.attributes.total.children.[0].children.[0].children.[0].children.[0] | Barrack Family | Cash | - | -1.44 | -1.44 | ||||
data.attributes.total.children.[0].children.[0].children.[1] | Barrack Family | Gratia Holdings No. 2 LLC | 8413655 | 55491732.66 | -0.971018847 | -0.971018847 | 11.52490309 | 55491732.66 | |
data.attributes.total.children.[0].children.[0].children.[1].children.[0] | Barrack Family | Investment Grade Fixed Income | - | 18469768.6 | 18469768.6 | ||||
data.attributes.total.children.[0].children.[0].children.[1].children.[1] | Barrack Family | High Yield Fixed Income | - | 3668982.44 | -0.205356545 | -0.205356545 | 4.441190127 | 3668982.44 |
I try and save only rows that contain 4x occurances of .children.[]
using the following statement -
Code: perf_by_entity_df = df[df['json_path'].str.contains(r'(\.children\.\[\d+\]){4}')]
However receive the following:
Error:UserWarning: This pattern is interpreted as a regular expression, and has match groups. To actually get the groups, use str.extract.
Any suggestions why this is happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用下面的代码来抑制警告:
Replace:
By:
来自 文档< /a>:
Use the code below to suppress the warning:
Replace:
By:
From the documentation: