Skip to content

Commit 8f8b177

Browse files
committed
BUG: not processing TypeError on reading some json (so was failing rather than trying not-numpy for dtypes)
1 parent b204e14 commit 8f8b177

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

pandas/io/json.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def _parse(self):
246246
labelled=True))
247247
else:
248248
self.obj = Series(loads(json, dtype=dtype, numpy=True))
249-
except ValueError:
249+
except (ValueError,TypeError):
250250
numpy = False
251251

252252
if not numpy:
@@ -296,7 +296,7 @@ def _parse(self):
296296
else:
297297
self.obj = DataFrame(*loads(json, dtype=dtype, numpy=True,
298298
labelled=True))
299-
except ValueError:
299+
except (ValueError,TypeError):
300300
numpy = False
301301

302302
if not numpy:

pandas/io/tests/test_json/test_pandas.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,18 @@ def test_weird_nested_json(self):
338338

339339
read_json(s)
340340

341+
@network
342+
@slow
343+
def test_round_trip_exception_(self):
344+
# GH 3867
345+
346+
df = pd.read_csv('https://raw.github.com/hayd/lahman2012/master/csvs/Teams.csv')
347+
s = df.to_json()
348+
result = pd.read_json(s)
349+
result.index = result.index.astype(int)
350+
result = result.reindex(columns=df.columns,index=df.index)
351+
assert_frame_equal(result,df)
352+
341353
@network
342354
@slow
343355
def test_url(self):

0 commit comments

Comments
 (0)