Skip to content

Commit

Permalink
Update json.py
Browse files Browse the repository at this point in the history
BUG : read_json with table='orient' causes unexpected type coercion pandas-dev#21345
  • Loading branch information
uds5501 authored Jun 10, 2018
1 parent 415012f commit cf34164
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pandas/io/json/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,12 +706,12 @@ def _try_convert_data(self, name, data, use_dtypes=True,
except (TypeError, ValueError):
pass

# do't coerce 0-len data
# don't coerce 0-len data
if len(data) and (data.dtype == 'float' or data.dtype == 'object'):

# coerce ints if we can
# coerce float if we can
try:
new_data = data.astype('int64')
new_data = data.astype('float64')
if (new_data == data).all():
data = new_data
result = True
Expand All @@ -721,7 +721,7 @@ 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
Expand Down

0 comments on commit cf34164

Please sign in to comment.