首页 > 解决方案 > 如何查询字段名称中有点的熊猫数据框

问题描述

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”未定义

标签: python-3.xpandas

解决方案


推荐阅读