Skip to content

Commit 37b4b33

Browse files
committed
Fix NoneType error when pulling non existent field
If normalizing a jsonstruct a field can be absent due to a schema change.
1 parent facd756 commit 37b4b33

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

pandas/io/json/_normalize.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -286,12 +286,16 @@ def _recursive_extract(data, path, seen_meta, level=0):
286286
else:
287287
for obj in data:
288288
recs = _pull_field(obj, path[0])
289-
recs = [
290-
nested_to_record(r, sep=sep, max_level=max_level)
291-
if isinstance(r, dict)
292-
else r
293-
for r in recs
294-
]
289+
recs = (
290+
[
291+
nested_to_record(r, sep=sep, max_level=max_level)
292+
if isinstance(r, dict)
293+
else r
294+
for r in recs
295+
]
296+
if recs
297+
else []
298+
)
295299

296300
# For repeating the metadata later
297301
lengths.append(len(recs))

0 commit comments

Comments
 (0)