Skip to content

Commit 8928270

Browse files
author
dickreuter
committed
Added documentation and test for issue #14505
1 parent 5aaf8fe commit 8928270

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

pandas/io/tests/json/test_json_norm.py

+45
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,51 @@ def test_nested_flattens(self):
225225

226226
self.assertEqual(result, expected)
227227

228+
def test_json_normalise_fix(self):
229+
j = {
230+
"Trades": [{
231+
"general": {
232+
"tradeid": 100,
233+
"trade_version": 1,
234+
"stocks": [{
235+
236+
"symbol": "AAPL",
237+
"name": "Apple",
238+
"price": "0"
239+
240+
}, {
241+
242+
"symbol": "GOOG",
243+
"name": "Google",
244+
"price": "0"
245+
246+
}
247+
]
248+
},
249+
}, {
250+
"general": {
251+
"tradeid": 100,
252+
"stocks": [{
253+
254+
"symbol": "AAPL",
255+
"name": "Apple",
256+
"price": "0"
257+
258+
}, {
259+
"symbol": "GOOG",
260+
"name": "Google",
261+
"price": "0"
262+
263+
}
264+
]
265+
},
266+
}
267+
]
268+
}
269+
j = json_normalize(data=j['Trades'], record_path=[['general', 'stocks']],
270+
meta=[['general', 'tradeid'], ['general', 'trade_version']])
271+
self.assertEqual(len(j), 4)
272+
228273
if __name__ == '__main__':
229274
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb',
230275
'--pdb-failure', '-s'], exit=False)

0 commit comments

Comments
 (0)