diff --git a/pandas/io/json/_json.py b/pandas/io/json/_json.py index c0499ce750cf0..73e4aeca29d72 100644 --- a/pandas/io/json/_json.py +++ b/pandas/io/json/_json.py @@ -1199,7 +1199,7 @@ def _convert_axes(self) -> None: name=axis_name, data=ser, use_dtypes=False, - convert_dates=True, + convert_dates=self.convert_dates, is_axis=True, ) if result: @@ -1346,6 +1346,12 @@ def _try_convert_to_date(self, data: Series) -> tuple[Series, bool]: "zones will raise an error", category=FutureWarning, ) + warnings.filterwarnings( + "ignore", + "The behavior of 'to_datetime' with 'unit' " + "when parsing strings is deprecated.*", + category=FutureWarning, + ) new_data = to_datetime(new_data, errors="raise", unit=date_unit) except (ValueError, OverflowError, TypeError): continue diff --git a/pandas/tests/io/json/test_pandas.py b/pandas/tests/io/json/test_pandas.py index 10f1e7df648f0..44d3dd47a4f5a 100644 --- a/pandas/tests/io/json/test_pandas.py +++ b/pandas/tests/io/json/test_pandas.py @@ -2186,3 +2186,9 @@ def test_read_json_lines_rangeindex(): result = read_json(StringIO(data), lines=True).index expected = RangeIndex(2) tm.assert_index_equal(result, expected, exact=True) + + +def test_read_json_to_datetime_futurewarning_supress(): + data = '{"A":{"0":"X","Y":"Y"}}' + with tm.assert_produces_warning(None): + read_json(StringIO(data))