Skip to content

Commit 1c6b786

Browse files
Merge master
Co-authored-by: Luca Ionescu <[email protected]>
1 parent d2b4e78 commit 1c6b786

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

doc/source/whatsnew/v1.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ Deprecations
545545
- :func:`pandas.json_normalize` is now exposed in the top-level namespace.
546546
Usage of ``json_normalize`` as ``pandas.io.json.json_normalize`` is now deprecated and
547547
it is recommended to use ``json_normalize`` as :func:`pandas.json_normalize` instead (:issue:`27586`).
548+
- The ``numpy`` argument of :meth:`pandas.read_json` is deprecated (:issue:`28512`).
548549
- :meth:`DataFrame.to_stata`, :meth:`DataFrame.to_feather`, and :meth:`DataFrame.to_parquet` argument "fname" is deprecated, use "path" instead (:issue:`23574`)
549550
- The deprecated internal attributes ``_start``, ``_stop`` and ``_step`` of :class:`RangeIndex` now raise a ``FutureWarning`` instead of a ``DeprecationWarning`` (:issue:`26581`)
550551

pandas/io/json/_json.py

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from pandas._libs.tslibs import iNaT
1212
from pandas._typing import JSONSerializable
1313
from pandas.errors import AbstractMethodError
14+
from pandas.util._decorators import deprecate_kwarg
1415

1516
from pandas.core.dtypes.common import ensure_str, is_period_dtype
1617

@@ -346,6 +347,7 @@ def _write(
346347
return serialized
347348

348349

350+
@deprecate_kwarg(old_arg_name="numpy", new_arg_name=None)
349351
def read_json(
350352
path_or_buf=None,
351353
orient=None,
@@ -459,6 +461,8 @@ def read_json(
459461
non-numeric column and index labels are supported. Note also that the
460462
JSON ordering MUST be the same for each term if numpy=True.
461463
464+
.. deprecated:: 1.0.0
465+
462466
precise_float : bool, default False
463467
Set to enable usage of higher precision (strtod) function when
464468
decoding string to double values. Default (False) is to use fast but

pandas/tests/io/json/test_pandas.py

+11
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from io import StringIO
44
import json
55
import os
6+
from warnings import catch_warnings, filterwarnings
67

78
import numpy as np
89
import pytest
@@ -1606,3 +1607,13 @@ def test_emca_262_nan_inf_support(self):
16061607
["a", np.nan, "NaN", np.inf, "Infinity", -np.inf, "-Infinity"]
16071608
)
16081609
tm.assert_frame_equal(result, expected)
1610+
1611+
@pytest.mark.filterwarnings("ignore:.*msgpack:FutureWarning")
1612+
def test_deprecate_numpy_argument_read_json(self):
1613+
# https://github.com/pandas-dev/pandas/issues/28512
1614+
expected = DataFrame([1, 2, 3])
1615+
with tm.assert_produces_warning(None):
1616+
with catch_warnings():
1617+
filterwarnings("ignore", category=FutureWarning)
1618+
result = read_json(expected.to_json(), numpy=True)
1619+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)