Skip to content

Commit b410978

Browse files
ylin00Kevin D Smith
authored and
Kevin D Smith
committed
Fixed pandas.json_normalize doctests errors` (pandas-dev#36207)
1 parent 5a4c9b1 commit b410978

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

pandas/io/json/_normalize.py

+17-17
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,11 @@ def _json_normalize(
163163
>>> data = [{'id': 1, 'name': {'first': 'Coleen', 'last': 'Volk'}},
164164
... {'name': {'given': 'Mose', 'family': 'Regner'}},
165165
... {'id': 2, 'name': 'Faye Raker'}]
166-
>>> pandas.json_normalize(data)
167-
id name name.family name.first name.given name.last
168-
0 1.0 NaN NaN Coleen NaN Volk
169-
1 NaN NaN Regner NaN Mose NaN
170-
2 2.0 Faye Raker NaN NaN NaN NaN
166+
>>> pd.json_normalize(data)
167+
id name.first name.last name.given name.family name
168+
0 1.0 Coleen Volk NaN NaN NaN
169+
1 NaN NaN NaN Mose Regner NaN
170+
2 2.0 NaN NaN NaN NaN Faye Raker
171171
172172
>>> data = [{'id': 1,
173173
... 'name': "Cole Volk",
@@ -176,11 +176,11 @@ def _json_normalize(
176176
... 'fitness': {'height': 130, 'weight': 60}},
177177
... {'id': 2, 'name': 'Faye Raker',
178178
... 'fitness': {'height': 130, 'weight': 60}}]
179-
>>> pandas.json_normalize(data, max_level=0)
180-
fitness id name
181-
0 {'height': 130, 'weight': 60} 1.0 Cole Volk
182-
1 {'height': 130, 'weight': 60} NaN Mose Reg
183-
2 {'height': 130, 'weight': 60} 2.0 Faye Raker
179+
>>> pd.json_normalize(data, max_level=0)
180+
id name fitness
181+
0 1.0 Cole Volk {'height': 130, 'weight': 60}
182+
1 NaN Mose Reg {'height': 130, 'weight': 60}
183+
2 2.0 Faye Raker {'height': 130, 'weight': 60}
184184
185185
Normalizes nested data up to level 1.
186186
@@ -191,11 +191,11 @@ def _json_normalize(
191191
... 'fitness': {'height': 130, 'weight': 60}},
192192
... {'id': 2, 'name': 'Faye Raker',
193193
... 'fitness': {'height': 130, 'weight': 60}}]
194-
>>> pandas.json_normalize(data, max_level=1)
195-
fitness.height fitness.weight id name
196-
0 130 60 1.0 Cole Volk
197-
1 130 60 NaN Mose Reg
198-
2 130 60 2.0 Faye Raker
194+
>>> pd.json_normalize(data, max_level=1)
195+
id name fitness.height fitness.weight
196+
0 1.0 Cole Volk 130 60
197+
1 NaN Mose Reg 130 60
198+
2 2.0 Faye Raker 130 60
199199
200200
>>> data = [{'state': 'Florida',
201201
... 'shortname': 'FL',
@@ -208,7 +208,7 @@ def _json_normalize(
208208
... 'info': {'governor': 'John Kasich'},
209209
... 'counties': [{'name': 'Summit', 'population': 1234},
210210
... {'name': 'Cuyahoga', 'population': 1337}]}]
211-
>>> result = pandas.json_normalize(data, 'counties', ['state', 'shortname',
211+
>>> result = pd.json_normalize(data, 'counties', ['state', 'shortname',
212212
... ['info', 'governor']])
213213
>>> result
214214
name population state shortname info.governor
@@ -219,7 +219,7 @@ def _json_normalize(
219219
4 Cuyahoga 1337 Ohio OH John Kasich
220220
221221
>>> data = {'A': [1, 2]}
222-
>>> pandas.json_normalize(data, 'A', record_prefix='Prefix.')
222+
>>> pd.json_normalize(data, 'A', record_prefix='Prefix.')
223223
Prefix.0
224224
0 1
225225
1 2

0 commit comments

Comments
 (0)