Skip to content

Commit db4d3b0

Browse files
authored
DEPR: Remove pandas.io.json.json_normalize in favor of pd.json_normalize (#50608)
1 parent 53c1425 commit db4d3b0

File tree

6 files changed

+3
-22
lines changed

6 files changed

+3
-22
lines changed

doc/source/whatsnew/v2.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ Removal of prior version deprecations/changes
522522
- Removed deprecated global option ``use_inf_as_null`` in favor of ``use_inf_as_na`` (:issue:`17126`)
523523
- Removed deprecated module ``pandas.core.index`` (:issue:`30193`)
524524
- Removed deprecated alias ``pandas.core.tools.datetimes.to_time``, import the function directly from ``pandas.core.tools.times`` instead (:issue:`34145`)
525+
- Removed deprecated alias ``pandas.io.json.json_normalize``, import the function directly from ``pandas.json_normalize`` instead (:issue:`27615`)
525526
- Removed deprecated :meth:`Categorical.to_dense`, use ``np.asarray(cat)`` instead (:issue:`32639`)
526527
- Removed deprecated :meth:`Categorical.take_nd` (:issue:`27745`)
527528
- Removed deprecated :meth:`Categorical.mode`, use ``Series(cat).mode()`` instead (:issue:`45033`)

pandas/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@
171171
read_spss,
172172
)
173173

174-
from pandas.io.json import _json_normalize as json_normalize
174+
from pandas.io.json._normalize import json_normalize
175175

176176
from pandas.util._tester import test
177177

pandas/io/json/__init__.py

-6
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,12 @@
44
read_json,
55
to_json,
66
)
7-
from pandas.io.json._normalize import (
8-
_json_normalize,
9-
json_normalize,
10-
)
117
from pandas.io.json._table_schema import build_table_schema
128

139
__all__ = [
1410
"dumps",
1511
"loads",
1612
"read_json",
1713
"to_json",
18-
"_json_normalize",
19-
"json_normalize",
2014
"build_table_schema",
2115
]

pandas/io/json/_normalize.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
IgnoreRaise,
2222
Scalar,
2323
)
24-
from pandas.util._decorators import deprecate
2524

2625
import pandas as pd
2726
from pandas import DataFrame
@@ -245,7 +244,7 @@ def _simple_json_normalize(
245244
return normalised_json_object
246245

247246

248-
def _json_normalize(
247+
def json_normalize(
249248
data: dict | list[dict],
250249
record_path: str | list | None = None,
251250
meta: str | list[str | list[str]] | None = None,
@@ -535,8 +534,3 @@ def _recursive_extract(data, path, seen_meta, level: int = 0) -> None:
535534
)
536535
result[k] = np.array(v, dtype=object).repeat(lengths)
537536
return result
538-
539-
540-
json_normalize = deprecate(
541-
"pandas.io.json.json_normalize", _json_normalize, "1.0.0", "pandas.json_normalize"
542-
)

pandas/tests/io/json/test_normalize.py

-7
Original file line numberDiff line numberDiff line change
@@ -872,13 +872,6 @@ def test_with_large_max_level(self):
872872
output = nested_to_record(input_data, max_level=max_level)
873873
assert output == expected
874874

875-
def test_deprecated_import(self):
876-
with tm.assert_produces_warning(FutureWarning):
877-
from pandas.io.json import json_normalize # pylint: disable=reimported
878-
879-
recs = [{"a": 1, "b": 2, "c": 3}, {"a": 4, "b": 5, "c": 6}]
880-
json_normalize(recs)
881-
882875
def test_series_non_zero_index(self):
883876
# GH 19020
884877
data = {

scripts/validate_unwanted_patterns.py

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
"_registry",
4949
"_get_offset", # TODO: remove after get_offset deprecation enforced
5050
"_test_parse_iso8601",
51-
"_json_normalize", # TODO: remove after deprecation is enforced
5251
"_testing",
5352
"_test_decorators",
5453
"__version__", # check np.__version__ in compat.numpy.function

0 commit comments

Comments
 (0)