diff --git a/pandas/io/json/json.py b/pandas/io/json/json.py index 1627b2f4d3ec3..641265a95e93b 100644 --- a/pandas/io/json/json.py +++ b/pandas/io/json/json.py @@ -706,10 +706,10 @@ def _try_convert_data(self, name, data, use_dtypes=True, except (TypeError, ValueError): pass - # do't coerce 0-len data - if len(data) and (data.dtype == 'float' or data.dtype == 'object'): + # don't coerce 0-len data + if len(data) and (data.dtype == 'object'): - # coerce ints if we can + # coerce int if we can try: new_data = data.astype('int64') if (new_data == data).all(): @@ -721,13 +721,23 @@ def _try_convert_data(self, name, data, use_dtypes=True, # coerce ints to 64 if data.dtype == 'int': - # coerce floats to 64 + # coerce ints to 64 try: data = data.astype('int64') result = True except (TypeError, ValueError): pass + # coerce floats to 64 + if data.dtype == 'float': + + # coerce floats to 64 + try: + data = data.astype('float64') + result = True + except (TypeError, ValueError): + pass + return data, result def _try_convert_to_date(self, data):