Skip to content

DEPR: Remove pandas.io.json.json_normalize in favor of pd.json_normalize #50608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v2.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ Removal of prior version deprecations/changes
- Removed deprecated global option ``use_inf_as_null`` in favor of ``use_inf_as_na`` (:issue:`17126`)
- Removed deprecated module ``pandas.core.index`` (:issue:`30193`)
- Removed deprecated alias ``pandas.core.tools.datetimes.to_time``, import the function directly from ``pandas.core.tools.times`` instead (:issue:`34145`)
- Removed deprecated alias ``pandas.io.json.json_normalize``, import the function directly from ``pandas.json_normalize`` instead (:issue:`27615`)
- Removed deprecated :meth:`Categorical.to_dense`, use ``np.asarray(cat)`` instead (:issue:`32639`)
- Removed deprecated :meth:`Categorical.take_nd` (:issue:`27745`)
- Removed deprecated :meth:`Categorical.mode`, use ``Series(cat).mode()`` instead (:issue:`45033`)
Expand Down
2 changes: 1 addition & 1 deletion pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
read_spss,
)

from pandas.io.json import _json_normalize as json_normalize
from pandas.io.json._normalize import json_normalize

from pandas.util._tester import test

Expand Down
6 changes: 0 additions & 6 deletions pandas/io/json/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@
read_json,
to_json,
)
from pandas.io.json._normalize import (
_json_normalize,
json_normalize,
)
from pandas.io.json._table_schema import build_table_schema

__all__ = [
"dumps",
"loads",
"read_json",
"to_json",
"_json_normalize",
"json_normalize",
"build_table_schema",
]
8 changes: 1 addition & 7 deletions pandas/io/json/_normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
IgnoreRaise,
Scalar,
)
from pandas.util._decorators import deprecate

import pandas as pd
from pandas import DataFrame
Expand Down Expand Up @@ -245,7 +244,7 @@ def _simple_json_normalize(
return normalised_json_object


def _json_normalize(
def json_normalize(
data: dict | list[dict],
record_path: str | list | None = None,
meta: str | list[str | list[str]] | None = None,
Expand Down Expand Up @@ -535,8 +534,3 @@ def _recursive_extract(data, path, seen_meta, level: int = 0) -> None:
)
result[k] = np.array(v, dtype=object).repeat(lengths)
return result


json_normalize = deprecate(
"pandas.io.json.json_normalize", _json_normalize, "1.0.0", "pandas.json_normalize"
)
7 changes: 0 additions & 7 deletions pandas/tests/io/json/test_normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,13 +872,6 @@ def test_with_large_max_level(self):
output = nested_to_record(input_data, max_level=max_level)
assert output == expected

def test_deprecated_import(self):
with tm.assert_produces_warning(FutureWarning):
from pandas.io.json import json_normalize # pylint: disable=reimported

recs = [{"a": 1, "b": 2, "c": 3}, {"a": 4, "b": 5, "c": 6}]
json_normalize(recs)

def test_series_non_zero_index(self):
# GH 19020
data = {
Expand Down
1 change: 0 additions & 1 deletion scripts/validate_unwanted_patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"_registry",
"_get_offset", # TODO: remove after get_offset deprecation enforced
"_test_parse_iso8601",
"_json_normalize", # TODO: remove after deprecation is enforced
"_testing",
"_test_decorators",
"__version__", # check np.__version__ in compat.numpy.function
Expand Down