Skip to content

Commit 149e193

Browse files
author
José Duarte
authored
TST: implement deserialization tests for older schema versions (#45048)
1 parent 7131268 commit 149e193

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

pandas/tests/io/json/test_json_table_schema.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,3 +789,25 @@ def test_empty_frame_roundtrip(self):
789789
out = df.to_json(orient="table")
790790
result = pd.read_json(out, orient="table")
791791
tm.assert_frame_equal(expected, result)
792+
793+
def test_read_json_orient_table_old_schema_version(self):
794+
df_json = """
795+
{
796+
"schema":{
797+
"fields":[
798+
{"name":"index","type":"integer"},
799+
{"name":"a","type":"string"}
800+
],
801+
"primaryKey":["index"],
802+
"pandas_version":"0.20.0"
803+
},
804+
"data":[
805+
{"index":0,"a":1},
806+
{"index":1,"a":2.0},
807+
{"index":2,"a":"s"}
808+
]
809+
}
810+
"""
811+
expected = DataFrame({"a": [1, 2.0, "s"]})
812+
result = pd.read_json(df_json, orient="table")
813+
tm.assert_frame_equal(expected, result)

0 commit comments

Comments
 (0)