@@ -1389,6 +1389,34 @@ def test_from_json_to_json_table_dtypes(self):
1389
1389
result = read_json (dfjson , orient = "table" )
1390
1390
tm .assert_frame_equal (result , expected )
1391
1391
1392
+ def test_to_json_from_json_columns_dtypes (self ):
1393
+ expected = DataFrame .from_dict (
1394
+ {
1395
+ "Integer" : pd .Series ([1 , 2 , 3 ], dtype = "int64" ),
1396
+ "Float" : pd .Series ([None , 2.0 , 3.0 ], dtype = "float64" ),
1397
+ "Object" : pd .Series ([None , "" , "c" ], dtype = "object" ),
1398
+ "Bool" : pd .Series ([True , False , True ], dtype = "bool" ),
1399
+ "Category" : pd .Series (["a" , "b" , None ], dtype = "category" ),
1400
+ "Datetime" : pd .Series (
1401
+ ["2020-01-01" , None , "2020-01-03" ], dtype = "datetime64[ns]"
1402
+ ),
1403
+ }
1404
+ )
1405
+ dfjson = expected .to_json (orient = "columns" )
1406
+ result = read_json (
1407
+ dfjson ,
1408
+ orient = "columns" ,
1409
+ dtype = {
1410
+ "Integer" : "int64" ,
1411
+ "Float" : "float64" ,
1412
+ "Object" : "object" ,
1413
+ "Bool" : "bool" ,
1414
+ "Category" : "category" ,
1415
+ "Datetime" : "datetime64[ns]" ,
1416
+ },
1417
+ )
1418
+ tm .assert_frame_equal (result , expected )
1419
+
1392
1420
@pytest .mark .parametrize ("dtype" , [True , {"b" : int , "c" : int }])
1393
1421
def test_read_json_table_dtype_raises (self , dtype ):
1394
1422
# GH21345
0 commit comments