Skip to content

Commit 5a5b347

Browse files
committed
add original changes.
1 parent 5c8bd04 commit 5a5b347

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
@@ -501,6 +501,7 @@ Deprecations
501501
- :func:`pandas.json_normalize` is now exposed in the top-level namespace.
502502
Usage of ``json_normalize`` as ``pandas.io.json.json_normalize`` is now deprecated and
503503
it is recommended to use ``json_normalize`` as :func:`pandas.json_normalize` instead (:issue:`27586`).
504+
- The ``numpy`` argument of :meth:`pandas.read_json` is deprecated (:issue:`28512`).
504505
-
505506

506507
.. _whatsnew_1000.prior_deprecations:

pandas/io/json/_json.py

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
)
2828
from pandas.io.formats.printing import pprint_thing
2929
from pandas.io.parsers import _validate_integer
30+
from pandas.util._decorators import deprecate_kwarg
3031

3132
from ._normalize import convert_to_line_delimits
3233
from ._table_schema import build_table_schema, parse_table_schema
@@ -353,6 +354,7 @@ def _write(
353354
return serialized
354355

355356

357+
@deprecate_kwarg(old_arg_name="numpy", new_arg_name=None)
356358
def read_json(
357359
path_or_buf=None,
358360
orient=None,
@@ -466,6 +468,8 @@ def read_json(
466468
non-numeric column and index labels are supported. Note also that the
467469
JSON ordering MUST be the same for each term if numpy=True.
468470
471+
.. deprecated:: 1.0.0
472+
469473
precise_float : bool, default False
470474
Set to enable usage of higher precision (strtod) function when
471475
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
@@ -1,6 +1,7 @@
11
from collections import OrderedDict
22
from datetime import timedelta
33
from io import StringIO
4+
from warnings import catch_warnings, filterwarnings
45
import json
56
import os
67

@@ -1601,3 +1602,13 @@ def test_json_indent_all_orients(self, orient, expected):
16011602
def test_json_negative_indent_raises(self):
16021603
with pytest.raises(ValueError, match="must be a nonnegative integer"):
16031604
pd.DataFrame().to_json(indent=-1)
1605+
1606+
@pytest.mark.filterwarnings("ignore:.*msgpack:FutureWarning")
1607+
def test_deprecate_numpy_argument_read_json(self):
1608+
# https://github.com/pandas-dev/pandas/issues/28512
1609+
df = DataFrame([1, 2, 3])
1610+
with tm.assert_produces_warning(None):
1611+
with catch_warnings():
1612+
filterwarnings("ignore", category=FutureWarning)
1613+
result = read_json(df.to_json(), numpy=True)
1614+
assert_frame_equal(result, df)

0 commit comments

Comments
 (0)