Skip to content

Commit

Permalink
code sample for pandas-dev#37783
Browse files Browse the repository at this point in the history
  • Loading branch information
simonjayhawkins committed Jun 3, 2022
1 parent 018c230 commit fe0d3e8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions bisect/37783.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# BUG: json_normalize generates TypeError: 'NoneType' object is not subscriptable
# as metadata object is not always present. #37783

import pandas as pd

print(pd.__version__)

file = [
{"values": ["1", "2"], "metadata": {"name": "first_value"}},
{"values": ["3", "4"], "metadata": None},
]

try:
df = pd.json_normalize(
file, record_path="values", meta=[["metadata", "name"]], errors="ignore"
)
except TypeError as e:
print(e)
else:
print(df)
exit(1)

0 comments on commit fe0d3e8

Please sign in to comment.