@@ -226,7 +226,7 @@ def _write(self, obj, orient, double_precision, ensure_ascii,
226
226
return serialized
227
227
228
228
229
- def read_json (path_or_buf = None , orient = None , typ = 'frame' , dtype = True ,
229
+ def read_json (path_or_buf = None , orient = None , typ = 'frame' , dtype = None ,
230
230
convert_axes = True , convert_dates = True , keep_default_dates = True ,
231
231
numpy = False , precise_float = False , date_unit = None , encoding = None ,
232
232
lines = False , chunksize = None , compression = 'infer' ):
@@ -277,9 +277,24 @@ def read_json(path_or_buf=None, orient=None, typ='frame', dtype=True,
277
277
'table' as an allowed value for the ``orient`` argument
278
278
279
279
typ : type of object to recover (series or frame), default 'frame'
280
- dtype : boolean or dict, default True
281
- If True, infer dtypes, if a dict of column to dtype, then use those,
280
+ dtype : boolean or dict
281
+ If True, infer dtypes; if a dict of column to dtype, then use those;
282
282
if False, then don't infer dtypes at all, applies only to the data.
283
+
284
+ The allowed and default values depend on the value of the `orient`
285
+ parameter:
286
+
287
+ - if ``orient != 'table'``:
288
+
289
+ - allowed ``dtype`` values are True, False or a dict
290
+ - default is True
291
+
292
+ - if ``orient == 'table'``:
293
+
294
+ - allowed and default ``dtype`` is False
295
+
296
+ .. versionchanged:: 0.24.2 set default False for ``orient='table'``
297
+
283
298
convert_axes : boolean, default True
284
299
Try to convert the axes to the proper dtypes.
285
300
convert_dates : boolean, default True
@@ -408,6 +423,9 @@ def read_json(path_or_buf=None, orient=None, typ='frame', dtype=True,
408
423
{"index": "row 2", "col 1": "c", "col 2": "d"}]}'
409
424
"""
410
425
426
+ if dtype and orient == 'table' :
427
+ raise ValueError ("'dtype' is only valid when 'orient' is not 'table'" )
428
+
411
429
compression = _infer_compression (path_or_buf , compression )
412
430
filepath_or_buffer , _ , compression , should_close = get_filepath_or_buffer (
413
431
path_or_buf , encoding = encoding , compression = compression ,
@@ -600,15 +618,19 @@ class Parser(object):
600
618
'us' : long (31536000000000 ),
601
619
'ns' : long (31536000000000000 )}
602
620
603
- def __init__ (self , json , orient , dtype = True , convert_axes = True ,
621
+ def __init__ (self , json , orient , dtype = None , convert_axes = True ,
604
622
convert_dates = True , keep_default_dates = False , numpy = False ,
605
623
precise_float = False , date_unit = None ):
606
624
self .json = json
607
625
608
626
if orient is None :
609
627
orient = self ._default_orient
610
-
611
628
self .orient = orient
629
+
630
+ if orient == 'table' :
631
+ dtype = False
632
+ if dtype is None :
633
+ dtype = True
612
634
self .dtype = dtype
613
635
614
636
if orient == "split" :
0 commit comments