diff --git a/asv_bench/benchmarks/tslibs/tslib.py b/asv_bench/benchmarks/tslibs/tslib.py index f93ef1cef841f..97ec80201dd16 100644 --- a/asv_bench/benchmarks/tslibs/tslib.py +++ b/asv_bench/benchmarks/tslibs/tslib.py @@ -51,7 +51,7 @@ class TimeIntsToPydatetime: _tzs, ) param_names = ["box", "size", "tz"] - # TODO: fold? freq? + # TODO: fold? def setup(self, box, size, tz): if box == "date" and tz is not None: diff --git a/pandas/core/arrays/_mixins.py b/pandas/core/arrays/_mixins.py index 35f1ace7ec351..0a4a550f5d8bc 100644 --- a/pandas/core/arrays/_mixins.py +++ b/pandas/core/arrays/_mixins.py @@ -234,21 +234,9 @@ def searchsorted( side: Literal["left", "right"] = "left", sorter: NumpySorter = None, ) -> npt.NDArray[np.intp] | np.intp: - # TODO(2.0): use _validate_setitem_value once dt64tz mismatched-timezone - # deprecation is enforced - npvalue = self._validate_searchsorted_value(value) + npvalue = self._validate_setitem_value(value) return self._ndarray.searchsorted(npvalue, side=side, sorter=sorter) - def _validate_searchsorted_value( - self, value: NumpyValueArrayLike | ExtensionArray - ) -> NumpyValueArrayLike: - # TODO(2.0): after deprecation in datetimelikearraymixin is enforced, - # we can remove this and use _validate_setitem_value directly - if isinstance(value, ExtensionArray): - return value.to_numpy() - else: - return value - @doc(ExtensionArray.shift) def shift(self, periods: int = 1, fill_value=None, axis: AxisInt = 0): diff --git a/pandas/core/arrays/categorical.py b/pandas/core/arrays/categorical.py index d58089af9a2a8..383d116a97964 100644 --- a/pandas/core/arrays/categorical.py +++ b/pandas/core/arrays/categorical.py @@ -1301,8 +1301,6 @@ def _validate_setitem_value(self, value): else: return self._validate_scalar(value) - _validate_searchsorted_value = _validate_setitem_value - def _validate_scalar(self, fill_value): """ Convert a user-facing fill_value to a representation to use with our diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index f98fbfe429871..b1d9fba22b484 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -600,7 +600,6 @@ def _validate_scalar( value, *, allow_listlike: bool = False, - setitem: bool = True, unbox: bool = True, ): """ @@ -612,8 +611,6 @@ def _validate_scalar( allow_listlike: bool, default False When raising an exception, whether the message should say listlike inputs are allowed. - setitem : bool, default True - Whether to check compatibility with setitem strictness. unbox : bool, default True Whether to unbox the result before returning. Note: unbox=False skips the setitem compatibility check. @@ -735,14 +732,6 @@ def _validate_listlike(self, value, allow_object: bool = False): return value - def _validate_searchsorted_value(self, value): - if not is_list_like(value): - return self._validate_scalar(value, allow_listlike=True, setitem=False) - else: - value = self._validate_listlike(value) - - return self._unbox(value) - def _validate_setitem_value(self, value): if is_list_like(value): value = self._validate_listlike(value) @@ -1363,10 +1352,7 @@ def _addsub_object_array(self, other: np.ndarray, op): # Caller is responsible for broadcasting if necessary assert self.shape == other.shape, (self.shape, other.shape) - with warnings.catch_warnings(): - # filter out warnings about Timestamp.freq - warnings.filterwarnings("ignore", category=FutureWarning) - res_values = op(self.astype("O"), np.asarray(other)) + res_values = op(self.astype("O"), np.asarray(other)) result = pd_array(res_values.ravel()) result = extract_array(result, extract_numpy=True).reshape(self.shape) diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py index 71002377293b7..6d31d0086d84b 100644 --- a/pandas/core/arrays/datetimes.py +++ b/pandas/core/arrays/datetimes.py @@ -751,7 +751,6 @@ def _add_offset(self, offset) -> DatetimeArray: else: result = DatetimeArray._simple_new(result, dtype=result.dtype) if self.tz is not None: - # FIXME: tz_localize with non-nano result = result.tz_localize(self.tz) return result diff --git a/pandas/core/arrays/period.py b/pandas/core/arrays/period.py index f7808a729fa0a..548aacda2f8b9 100644 --- a/pandas/core/arrays/period.py +++ b/pandas/core/arrays/period.py @@ -692,7 +692,7 @@ def searchsorted( side: Literal["left", "right"] = "left", sorter: NumpySorter = None, ) -> npt.NDArray[np.intp] | np.intp: - npvalue = self._validate_searchsorted_value(value).view("M8[ns]") + npvalue = self._validate_setitem_value(value).view("M8[ns]") # Cast to M8 to get datetime-like NaT placement m8arr = self._ndarray.view("M8[ns]") diff --git a/pandas/core/dtypes/cast.py b/pandas/core/dtypes/cast.py index 02fae6a5d618b..ac7eb95eb4f15 100644 --- a/pandas/core/dtypes/cast.py +++ b/pandas/core/dtypes/cast.py @@ -1029,15 +1029,12 @@ def soft_convert_objects( if datetime or timedelta: # GH 20380, when datetime is beyond year 2262, hence outside # bound of nanosecond-resolution 64-bit integers. - try: - converted = lib.maybe_convert_objects( - values, - convert_datetime=datetime, - convert_timedelta=timedelta, - convert_period=period, - ) - except (OutOfBoundsDatetime, ValueError): - return values + converted = lib.maybe_convert_objects( + values, + convert_datetime=datetime, + convert_timedelta=timedelta, + convert_period=period, + ) if converted is not values: return converted diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 4da8d1a11c607..0d199c47345a6 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -3500,13 +3500,7 @@ def _assert_can_do_setop(self, other) -> bool: def _convert_can_do_setop(self, other) -> tuple[Index, Hashable]: if not isinstance(other, Index): - # TODO(2.0): no need to special-case here once _with_infer - # deprecation is enforced - if hasattr(other, "dtype"): - other = Index(other, name=self.name, dtype=other.dtype) - else: - # e.g. list - other = Index(other, name=self.name) + other = Index(other, name=self.name) result_name = self.name else: result_name = get_op_result_name(self, other) diff --git a/pandas/core/internals/blocks.py b/pandas/core/internals/blocks.py index 66071ea4edf52..cab8901ff3596 100644 --- a/pandas/core/internals/blocks.py +++ b/pandas/core/internals/blocks.py @@ -1920,15 +1920,11 @@ def _catch_deprecated_value_error(err: Exception) -> None: which will no longer be raised in version.2.0. """ if isinstance(err, ValueError): - # TODO(2.0): once DTA._validate_setitem_value deprecation - # is enforced, stop catching ValueError here altogether if isinstance(err, IncompatibleFrequency): pass elif "'value.closed' is" in str(err): # IntervalDtype mismatched 'closed' pass - elif "Timezones don't match" not in str(err): - raise err class DatetimeLikeBlock(NDArrayBackedExtensionBlock): diff --git a/pandas/plotting/_matplotlib/core.py b/pandas/plotting/_matplotlib/core.py index 64b5bafa97849..dea5dbd33bbdf 100644 --- a/pandas/plotting/_matplotlib/core.py +++ b/pandas/plotting/_matplotlib/core.py @@ -1180,11 +1180,7 @@ def _plot_colorbar(self, ax: Axes, **kwds): # use the last one which contains the latest information # about the ax img = ax.collections[-1] - with warnings.catch_warnings(): - # https://github.com/matplotlib/matplotlib/issues/23614 - # False positive deprecation warning until matplotlib=3.6 - warnings.filterwarnings("ignore", "Auto-removal of grids") - return self.fig.colorbar(img, ax=ax, **kwds) + return self.fig.colorbar(img, ax=ax, **kwds) class ScatterPlot(PlanePlot): diff --git a/pandas/tests/apply/test_frame_transform.py b/pandas/tests/apply/test_frame_transform.py index 4749cec018fe6..73a52534dd0d2 100644 --- a/pandas/tests/apply/test_frame_transform.py +++ b/pandas/tests/apply/test_frame_transform.py @@ -130,6 +130,10 @@ def func(x): frame_kernels_raise = [x for x in frame_transform_kernels if x not in wont_fail] +@pytest.mark.filterwarnings( + "ignore:Calling Series.rank with numeric_only:FutureWarning" +) +@pytest.mark.filterwarnings("ignore:Dropping of nuisance:FutureWarning") @pytest.mark.parametrize("op", [*frame_kernels_raise, lambda x: x + 1]) def test_transform_bad_dtype(op, frame_or_series, request): # GH 35964 @@ -162,6 +166,12 @@ def test_transform_bad_dtype(op, frame_or_series, request): obj.transform({"A": [op]}) +@pytest.mark.filterwarnings( + "ignore:Dropping of nuisance columns in Series.rank:FutureWarning" +) +@pytest.mark.filterwarnings( + "ignore:Calling Series.rank with numeric_only:FutureWarning" +) @pytest.mark.parametrize("op", frame_kernels_raise) def test_transform_failure_typeerror(request, op): # GH 35964 diff --git a/pandas/tests/apply/test_series_apply.py b/pandas/tests/apply/test_series_apply.py index 9b51ea7fef5f8..e0d3510ac3865 100644 --- a/pandas/tests/apply/test_series_apply.py +++ b/pandas/tests/apply/test_series_apply.py @@ -275,6 +275,8 @@ def test_transform(string_series): tm.assert_series_equal(result.reindex_like(expected), expected) +@pytest.mark.filterwarnings("ignore:Calling Series.rank:FutureWarning") +@pytest.mark.filterwarnings("ignore:Dropping of nuisance:FutureWarning") @pytest.mark.parametrize("op", series_transform_kernels) def test_transform_partial_failure(op, request): # GH 35964 diff --git a/pandas/tests/arithmetic/test_datetime64.py b/pandas/tests/arithmetic/test_datetime64.py index 0b1d56a956c07..bad5335ad2d58 100644 --- a/pandas/tests/arithmetic/test_datetime64.py +++ b/pandas/tests/arithmetic/test_datetime64.py @@ -649,7 +649,6 @@ def test_comparison_tzawareness_compat_scalars(self, comparison_op, box_with_arr # Raising in __eq__ will fallback to NumPy, which warns, fails, # then re-raises the original exception. So we just need to ignore. @pytest.mark.filterwarnings("ignore:elementwise comp:DeprecationWarning") - @pytest.mark.filterwarnings("ignore:Converting timezone-aware:FutureWarning") def test_scalar_comparison_tzawareness( self, comparison_op, other, tz_aware_fixture, box_with_array ): diff --git a/pandas/tests/arithmetic/test_timedelta64.py b/pandas/tests/arithmetic/test_timedelta64.py index bb7949c9f08e2..14d50acf3eadf 100644 --- a/pandas/tests/arithmetic/test_timedelta64.py +++ b/pandas/tests/arithmetic/test_timedelta64.py @@ -1730,6 +1730,7 @@ def test_td64arr_floordiv_td64arr_with_nat( result = np.asarray(left) // right tm.assert_equal(result, expected) + @pytest.mark.filterwarnings("ignore:invalid value encountered:RuntimeWarning") def test_td64arr_floordiv_tdscalar(self, box_with_array, scalar_td): # GH#18831, GH#19125 box = box_with_array diff --git a/pandas/tests/arrays/test_datetimes.py b/pandas/tests/arrays/test_datetimes.py index 37a9c19627ada..564194ed4a9d3 100644 --- a/pandas/tests/arrays/test_datetimes.py +++ b/pandas/tests/arrays/test_datetimes.py @@ -81,7 +81,7 @@ def test_non_nano(self, unit, reso, dtype): def test_fields(self, unit, reso, field, dtype, dta_dti): dta, dti = dta_dti - # FIXME: assert (dti == dta).all() + assert (dti == dta).all() res = getattr(dta, field) expected = getattr(dti._data, field) diff --git a/pandas/tests/extension/base/dim2.py b/pandas/tests/extension/base/dim2.py index 85e19f1860b21..210e566c7e463 100644 --- a/pandas/tests/extension/base/dim2.py +++ b/pandas/tests/extension/base/dim2.py @@ -200,7 +200,7 @@ def test_reductions_2d_axis0(self, data, method): kwargs["ddof"] = 0 try: - if method == "mean" and hasattr(data, "_mask"): + if method in ["mean", "var"] and hasattr(data, "_mask"): # Empty slices produced by the mask cause RuntimeWarnings by numpy with tm.assert_produces_warning(RuntimeWarning, check_stacklevel=False): result = getattr(arr2d, method)(axis=0, **kwargs) diff --git a/pandas/tests/extension/test_arrow.py b/pandas/tests/extension/test_arrow.py index d44944c74f9d5..d094a7731c417 100644 --- a/pandas/tests/extension/test_arrow.py +++ b/pandas/tests/extension/test_arrow.py @@ -499,6 +499,9 @@ def test_in_numeric_groupby(self, data_for_grouping, request): ) super().test_in_numeric_groupby(data_for_grouping) + @pytest.mark.filterwarnings( + "ignore:The default value of numeric_only:FutureWarning" + ) @pytest.mark.parametrize("as_index", [True, False]) def test_groupby_extension_agg(self, as_index, data_for_grouping, request): pa_dtype = data_for_grouping.dtype.pyarrow_dtype diff --git a/pandas/tests/frame/methods/test_quantile.py b/pandas/tests/frame/methods/test_quantile.py index 3beb201bcfa05..14b416011b956 100644 --- a/pandas/tests/frame/methods/test_quantile.py +++ b/pandas/tests/frame/methods/test_quantile.py @@ -751,9 +751,6 @@ def test_quantile_empty_no_rows_ints(self, interp_method): exp = Series([np.nan, np.nan], index=["a", "b"], name=0.5) tm.assert_series_equal(res, exp) - @pytest.mark.filterwarnings( - "ignore:The behavior of DatetimeArray._from_sequence:FutureWarning" - ) def test_quantile_empty_no_rows_dt64(self, interp_method): interpolation, method = interp_method # datetimes diff --git a/pandas/tests/frame/methods/test_shift.py b/pandas/tests/frame/methods/test_shift.py index 3b33d0cc80445..c44c0bd566585 100644 --- a/pandas/tests/frame/methods/test_shift.py +++ b/pandas/tests/frame/methods/test_shift.py @@ -564,8 +564,6 @@ def test_shift_dt64values_int_fill_deprecated(self): ], ids=lambda x: str(x.dtype), ) - # TODO(2.0): remove filtering - @pytest.mark.filterwarnings("ignore:Index.ravel.*:FutureWarning") def test_shift_dt64values_axis1_invalid_fill(self, vals, as_cat): # GH#44564 ser = Series(vals) diff --git a/pandas/tests/generic/test_finalize.py b/pandas/tests/generic/test_finalize.py index 689caffe98a2d..6bd9b8af766c3 100644 --- a/pandas/tests/generic/test_finalize.py +++ b/pandas/tests/generic/test_finalize.py @@ -482,6 +482,9 @@ def test_finalize_called_eval_numexpr(): # Binary operations +@pytest.mark.filterwarnings( + "ignore:Automatic reindexing on DataFrame vs Series:FutureWarning" +) @pytest.mark.parametrize("annotate", ["left", "right", "both"]) @pytest.mark.parametrize( "args", diff --git a/pandas/tests/groupby/aggregate/test_other.py b/pandas/tests/groupby/aggregate/test_other.py index 6740729d038a7..9aa58e919ce24 100644 --- a/pandas/tests/groupby/aggregate/test_other.py +++ b/pandas/tests/groupby/aggregate/test_other.py @@ -25,6 +25,7 @@ from pandas.io.formats.printing import pprint_thing +@pytest.mark.filterwarnings("ignore:Dropping invalid columns:FutureWarning") def test_agg_partial_failure_raises(): # GH#43741 diff --git a/pandas/tests/indexes/datetimes/methods/test_snap.py b/pandas/tests/indexes/datetimes/methods/test_snap.py index a94d00d919082..755f6cff1278f 100644 --- a/pandas/tests/indexes/datetimes/methods/test_snap.py +++ b/pandas/tests/indexes/datetimes/methods/test_snap.py @@ -26,7 +26,6 @@ def astype_non_nano(dti_nano, unit): return dti -@pytest.mark.filterwarnings("ignore::DeprecationWarning") @pytest.mark.parametrize("tz", [None, "Asia/Shanghai", "Europe/Berlin"]) @pytest.mark.parametrize("name", [None, "my_dti"]) @pytest.mark.parametrize("unit", ["ns", "us", "ms", "s"]) diff --git a/pandas/tests/indexes/test_any_index.py b/pandas/tests/indexes/test_any_index.py index 6d4e7caacc5e4..3b3d6dbaf697f 100644 --- a/pandas/tests/indexes/test_any_index.py +++ b/pandas/tests/indexes/test_any_index.py @@ -133,8 +133,6 @@ def test_slice_keeps_name(self, index): assert index.name == index[1:].name @pytest.mark.parametrize("item", [101, "no_int", 2.5]) - # FutureWarning from non-tuple sequence of nd indexing - @pytest.mark.filterwarnings("ignore::FutureWarning") def test_getitem_error(self, index, item): msg = "|".join( [ @@ -145,8 +143,6 @@ def test_getitem_error(self, index, item): "are valid indices" ), "index out of bounds", # string[pyarrow] - "Only integers, slices and integer or " - "boolean arrays are valid indices.", # string[pyarrow] ] ) with pytest.raises(IndexError, match=msg): diff --git a/pandas/tests/indexes/test_base.py b/pandas/tests/indexes/test_base.py index ef041d7f9e119..5b8650dade745 100644 --- a/pandas/tests/indexes/test_base.py +++ b/pandas/tests/indexes/test_base.py @@ -230,7 +230,6 @@ def test_constructor_simple_new(self, vals, dtype): result = index._simple_new(index.values, dtype) tm.assert_index_equal(result, index) - @pytest.mark.filterwarnings("ignore:Passing keywords other:FutureWarning") @pytest.mark.parametrize("attr", ["values", "asi8"]) @pytest.mark.parametrize("klass", [Index, DatetimeIndex]) def test_constructor_dtypes_datetime(self, tz_naive_fixture, attr, klass): @@ -1498,7 +1497,6 @@ def test_index_subclass_constructor_wrong_kwargs(index_maker): index_maker(foo="bar") -@pytest.mark.filterwarnings("ignore:Passing keywords other:FutureWarning") def test_deprecated_fastpath(): msg = "[Uu]nexpected keyword argument" with pytest.raises(TypeError, match=msg): diff --git a/pandas/tests/series/accessors/test_dt_accessor.py b/pandas/tests/series/accessors/test_dt_accessor.py index ccd79d5cc58f4..1e929cd43842b 100644 --- a/pandas/tests/series/accessors/test_dt_accessor.py +++ b/pandas/tests/series/accessors/test_dt_accessor.py @@ -731,7 +731,6 @@ def test_dt_timetz_accessor(self, tz_naive_fixture): [["2016-01-07", "2016-01-01"], [[2016, 1, 4], [2015, 53, 5]]], ], ) - @pytest.mark.filterwarnings("ignore:Inferring datetime64:FutureWarning") def test_isocalendar(self, input_series, expected_output): result = pd.to_datetime(Series(input_series)).dt.isocalendar() expected_frame = DataFrame( diff --git a/pandas/tests/test_downstream.py b/pandas/tests/test_downstream.py index cea9484fbbf80..a7f4269fa62b1 100644 --- a/pandas/tests/test_downstream.py +++ b/pandas/tests/test_downstream.py @@ -156,7 +156,6 @@ def test_oo_optimized_datetime_index_unpickle(): @pytest.mark.network @tm.network # Cython import warning -@pytest.mark.filterwarnings("ignore:pandas.util.testing is deprecated") @pytest.mark.filterwarnings("ignore:can't:ImportWarning") @pytest.mark.filterwarnings("ignore:.*64Index is deprecated:FutureWarning") @pytest.mark.filterwarnings(