我正在尝试调用
expect_column_values_to_match_json_schema
如所述
jschema = {
"type" : "object",
"properties" : {
"xyz" : {"type" : "string"}
}
}
df_ge.expect_column_values_to_match_json_schema(column='abc',json_schema=jschema,row_condition="a=='1' and b=='2' and c=='3'",condition_parser='pandas')然而,我得到了这个错误
File "/some/path/lib/python3.7/site-packages/great_expectations/dataset/pandas_dataset.py", line 1554, in matches_json_schema
val_json = json.loads(val)
File "/usr/lib/python3.7/json/__init__.py", line 341, in loads
raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not dict所以我试着
df_ge.expect_column_values_to_match_json_schema(column='abc',json_schema=json.loads(str(jschema)),row_condition="a=='1' and b=='2' and c=='3'",condition_parser='pandas')但后来我得到了
df_ge.expect_column_values_to_match_json_schema(column='pg',json_schema=json.loads(str(pgschema)),row_condition="a=='1' and b=='2' and c=='3'",condition_parser='pandas')
File "/usr/lib/python3.7/json/__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.7/json/decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)我如何创建一个合适的json对象来提供给这个方法?
发布于 2021-10-14 18:14:37
没有"JSON对象“这回事。JSON是一种序列化格式,所以唯一可以是JSON的是一个字节字符串。这样的字符串可以用与json.loads完全相反的方式创建,即json.dumps
df_ge.expect_column_values_to_match_json_schema(column='pg',json_schema=json.dumps(pgschema),row_condition="a=='1' and b=='2' and c=='3'",condition_parser='pandas')https://stackoverflow.com/questions/69575380
复制相似问题