python-3.x - 如何查询字段名称中有点的熊猫数据框
问题描述
from pandas.io.json import json_normalize
record = {'a': {'b': 1, 'c': 2}}
df = json_normalize(record)
print(df.query("a.b == 1"))
打印以下错误:文件“C:\Python37\lib\site-packages\pandas\core\computation\scope.py”,第 194 行,在解决
raise compu.ops.UndefinedVariableError(key, is_local)
pandas.core.computation。 ops.UndefinedVariableError:名称“a”未定义
解决方案
推荐阅读
- c# - 修改实体后 DbContext.SaveChanges() 不更新数据库
- regex - Scala - 如何在带有正则表达式的 s3:/ 前缀之后提取路径?
- r - 手动将填充颜色绑定到值
- mongodb - Mongodb 带索引的排序性能
- c# - 如何使用 C# 在 Github 中自动创建问题
- json - 接收 JSON 对象,是否需要“包装”方括号?
- php - Codeingiter 以更快的方式获取计数
- python - 是否有 Ansible 的客户端/代理软件?
- apache-spark - 如何在不分叉/修改 Spark 本身的情况下创建自定义 Spark-Native 函数
- c# - 代码中的字符串与文件中的字符串有什么区别