Skip to content

Commit ddbe74c

Browse files
authored
Update meta validation to allow lists of strings
1 parent cab741a commit ddbe74c

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

pandas/io/json/_normalize.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def _simple_json_normalize(
269269

270270
def _validate_meta(meta: list) -> None:
271271
"""
272-
Validate that meta parameter contains only strings.
272+
Validate that meta parameter contains only strings or lists of strings.
273273
274274
Parameters
275275
----------
@@ -279,12 +279,19 @@ def _validate_meta(meta: list) -> None:
279279
Raises
280280
------
281281
TypeError
282-
If meta contains non-string elements.
282+
If meta contains elements that are not strings or lists of strings.
283283
"""
284284
for item in meta:
285-
if not isinstance(item, str):
285+
if isinstance(item, list):
286+
for subitem in item:
287+
if not isinstance(subitem, str):
288+
raise TypeError(
289+
"All elements in nested meta paths must be strings. "
290+
f"Found {type(subitem).__name__}: {subitem!r}"
291+
)
292+
elif not isinstance(item, str):
286293
raise TypeError(
287-
"All elements in 'meta' must be strings. "
294+
"All elements in 'meta' must be strings or lists of strings. "
288295
f"Found {type(item).__name__}: {item!r}"
289296
)
290297

0 commit comments

Comments
 (0)