Skip to content

Commit 25fd0f8

Browse files
author
Felix Marczinowski
committed
move test, fix py3 issue
1 parent 7a38110 commit 25fd0f8

File tree

3 files changed

+16
-24
lines changed

3 files changed

+16
-24
lines changed

pandas/io/json.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ def nested_to_record(ds, prefix="", level=0):
614614
new_d = copy.deepcopy(d)
615615
for k, v in d.items():
616616
# each key gets renamed with prefix
617-
if not isinstance(k, basestring):
617+
if not isinstance(k, compat.string_types):
618618
k = str(k)
619619
if level == 0:
620620
newkey = k

pandas/io/tests/json/test_json_norm.py

+15
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from pandas import DataFrame
44
import numpy as np
5+
import json
56

67
import pandas.util.testing as tm
78

@@ -164,6 +165,20 @@ def test_record_prefix(self):
164165

165166
tm.assert_frame_equal(result, expected)
166167

168+
def test_non_ascii_key(self):
169+
testjson = '[{"\xc3\x9cnic\xc3\xb8de":0,"sub":{"A":1, "B":2}},' \
170+
'{"\xc3\x9cnic\xc3\xb8de":1,"sub":{"A":3, "B":4}}]'
171+
172+
testdata = {
173+
u'sub.A': [1, 3],
174+
u'sub.B': [2, 4],
175+
"\xc3\x9cnic\xc3\xb8de".decode('utf8'): [0, 1]
176+
}
177+
testdf = DataFrame(testdata)
178+
179+
df = json_normalize(json.loads(testjson))
180+
tm.assert_frame_equal(df, testdf)
181+
167182

168183
class TestNestedToRecord(tm.TestCase):
169184

pandas/tests/frame/test_json.py

-23
This file was deleted.

0 commit comments

Comments
 (0)