The Problem
Real data moment
A real response from GitHub's own public REST API — GET /repos/pandas-dev/pandas, trimmed to a handful of fields:
{
"name": "pandas",
"full_name": "pandas-dev/pandas",
"owner": {
"login": "pandas-dev",
"type": "Organization"
},
"license": {
"name": "BSD 3-Clause \"New\" or \"Revised\" License",
"spdx_id": "BSD-3-Clause"
},
"stargazers_count": 49301,
"forks_count": 20165,
"topics": ["alignment", "data-analysis", "data-science", "flexible", "pandas", "python"]
}
owner and license are objects nested inside the repository object — not separate rows, not separate tables, just fields whose own values happen to be more JSON. A CSV has no way to express that. A DataFrame's rows-and-columns shape doesn't either, not directly — something has to decide how owner.login becomes its own column before this can become a DataFrame at all.
The gotcha
df_shallow = pd.json_normalize(repo, max_level=0)
print(df_shallow.columns.tolist())
print(df_shallow["owner"].iloc[0])
print(type(df_shallow["owner"].iloc[0]))
['name', 'full_name', 'owner', 'license', 'stargazers_count', 'forks_count', 'topics']
{'login': 'pandas-dev', 'type': 'Organization'}
<class 'dict'>
With max_level=0, owner and license never get flattened at all — they stay as raw Python dict objects, sitting inside single DataFrame cells. The DataFrame loads without any error and looks reasonable at a glance (df_shallow.head() would show an owner column, just like before). It's only when you try to actually filter or group by owner.login — and discover there's no such column, only a column full of unflattened dicts — that the problem becomes visible.
This isn't really "dropping" data — it's worse, because nothing is missing
Every real value is still technically present in a max_level=0 DataFrame; it's just trapped one layer too deep to use normally (df["owner"]["login"] doesn't work the way df["owner.login"] would). A column full of dicts doesn't raise an error until you try to actually use it as a column, which can be several steps after the data was loaded — further from the actual mistake than an immediate crash would be.
A different nested API response has this shape: {"id": 42, "author": {"name": "Ada", "profile": {"country": "UK", "verified": true}}}. Using json_normalize with default settings (no max_level specified), what column names does the fully-flattened result have?
Default json_normalize flattens every level of nesting, not just the first — author.profile itself contains two more fields, so full flattening reaches all the way down to author.profile.country and author.profile.verified, each becoming its own column. id was never nested, so it stays as its own plain column, unaffected and not dropped.