Skip to content
Merged
4 changes: 4 additions & 0 deletions doc/source/user_guide/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2066,6 +2066,8 @@ The Numpy parameter
+++++++++++++++++++

.. note::
This param has been deprecated as of version 1.0.0 and will raise a ``FutureWarning``.

This supports numeric data only. Index and columns labels may be non-numeric, e.g. strings, dates etc.

If ``numpy=True`` is passed to ``read_json`` an attempt will be made to sniff
Expand All @@ -2088,6 +2090,7 @@ data:
%timeit pd.read_json(jsonfloats)

.. ipython:: python
:okwarning:

%timeit pd.read_json(jsonfloats, numpy=True)

Expand All @@ -2102,6 +2105,7 @@ The speedup is less noticeable for smaller datasets:
%timeit pd.read_json(jsonfloats)

.. ipython:: python
:okwarning:

%timeit pd.read_json(jsonfloats, numpy=True)

Expand Down
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ Deprecations
- :func:`pandas.json_normalize` is now exposed in the top-level namespace.
Usage of ``json_normalize`` as ``pandas.io.json.json_normalize`` is now deprecated and
it is recommended to use ``json_normalize`` as :func:`pandas.json_normalize` instead (:issue:`27586`).
- The ``numpy`` argument of :meth:`pandas.read_json` is deprecated (:issue:`28512`).
- :meth:`DataFrame.to_stata`, :meth:`DataFrame.to_feather`, and :meth:`DataFrame.to_parquet` argument "fname" is deprecated, use "path" instead (:issue:`23574`)
- The deprecated internal attributes ``_start``, ``_stop`` and ``_step`` of :class:`RangeIndex` now raise a ``FutureWarning`` instead of a ``DeprecationWarning`` (:issue:`26581`)
- The ``pandas.util.testing`` module has been deprecated. Use the public API in ``pandas.testing`` documented at :ref:`api.general.testing` (:issue:`16232`).
Expand Down
4 changes: 4 additions & 0 deletions pandas/io/json/_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from pandas._libs.tslibs import iNaT
from pandas._typing import JSONSerializable
from pandas.errors import AbstractMethodError
from pandas.util._decorators import deprecate_kwarg

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

Expand Down Expand Up @@ -346,6 +347,7 @@ def _write(
return serialized


@deprecate_kwarg(old_arg_name="numpy", new_arg_name=None)
def read_json(
path_or_buf=None,
orient=None,
Expand Down Expand Up @@ -459,6 +461,8 @@ def read_json(
non-numeric column and index labels are supported. Note also that the
JSON ordering MUST be the same for each term if numpy=True.

.. deprecated:: 1.0.0

precise_float : bool, default False
Set to enable usage of higher precision (strtod) function when
decoding string to double values. Default (False) is to use fast but
Expand Down
8 changes: 8 additions & 0 deletions pandas/tests/io/json/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def assert_json_roundtrip_equal(result, expected, orient):
tm.assert_frame_equal(result, expected)


@pytest.mark.filterwarnings("ignore:the 'numpy' keyword is deprecated:FutureWarning")
class TestPandasContainer:
@pytest.fixture(scope="function", autouse=True)
def setup(self, datapath):
Expand Down Expand Up @@ -1606,3 +1607,10 @@ def test_emca_262_nan_inf_support(self):
["a", np.nan, "NaN", np.inf, "Infinity", -np.inf, "-Infinity"]
)
tm.assert_frame_equal(result, expected)

def test_deprecate_numpy_argument_read_json(self):
# GH 28512
expected = DataFrame([1, 2, 3])
with tm.assert_produces_warning(FutureWarning):
result = read_json(expected.to_json(), numpy=True)
tm.assert_frame_equal(result, expected)