Skip to content

Commit 9b2efe2

Browse files
committed
MNT: Add comments explaining meta_keys logic in json_normalize
1 parent 84233a2 commit 9b2efe2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pandas/io/json/_normalize.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,12 @@ def _pull_records(js: dict[str, Any], spec: list | str) -> list:
555555
meta_keys = []
556556
for val in _meta:
557557
if len(val) == 1:
558+
# Simple path: [12] -> 12 (preserves int type for consistency)
559+
# Use the key directly, avoiding sep.join
558560
meta_keys.append(val[0])
559561
else:
562+
# Nested path: ['info', 'governor'] -> "info.governor"
563+
# Must join, converting all parts to str to avoid TypeError
560564
meta_keys.append(sep.join(str(x) for x in val))
561565

562566
def _recursive_extract(data, path, seen_meta, level: int = 0) -> None:

0 commit comments

Comments
 (0)