diff --git a/doc/source/reference/frame.rst b/doc/source/reference/frame.rst index 37d27093efefdc..4540504974f56a 100644 --- a/doc/source/reference/frame.rst +++ b/doc/source/reference/frame.rst @@ -30,7 +30,6 @@ Attributes and underlying data DataFrame.dtypes DataFrame.ftypes DataFrame.get_dtype_counts - DataFrame.get_ftype_counts DataFrame.select_dtypes DataFrame.values DataFrame.get_values @@ -40,7 +39,6 @@ Attributes and underlying data DataFrame.shape DataFrame.memory_usage DataFrame.empty - DataFrame.is_copy Conversion ~~~~~~~~~~ @@ -142,8 +140,6 @@ Computations / descriptive stats DataFrame.all DataFrame.any DataFrame.clip - DataFrame.clip_lower - DataFrame.clip_upper DataFrame.compound DataFrame.corr DataFrame.corrwith diff --git a/doc/source/reference/series.rst b/doc/source/reference/series.rst index 59910ba3571301..c501e8bc91379c 100644 --- a/doc/source/reference/series.rst +++ b/doc/source/reference/series.rst @@ -45,7 +45,6 @@ Attributes Series.dtypes Series.ftypes Series.data - Series.is_copy Series.name Series.put @@ -148,8 +147,6 @@ Computations / descriptive stats Series.autocorr Series.between Series.clip - Series.clip_lower - Series.clip_upper Series.corr Series.count Series.cov diff --git a/doc/source/whatsnew/v1.0.0.rst b/doc/source/whatsnew/v1.0.0.rst index d110b28754d3a8..70c30eb42169b7 100644 --- a/doc/source/whatsnew/v1.0.0.rst +++ b/doc/source/whatsnew/v1.0.0.rst @@ -333,6 +333,11 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more. - Removed previously deprecated "nthreads" argument from :func:`read_feather`, use "use_threads" instead (:issue:`23053`) - Removed :meth:`Index.is_lexsorted_for_tuple` (:issue:`29305`) - Removed support for nexted renaming in :meth:`DataFrame.aggregate`, :meth:`Series.aggregate`, :meth:`DataFrameGroupBy.aggregate`, :meth:`SeriesGroupBy.aggregate`, :meth:`Rolling.aggregate` (:issue:`29608`) +- Removed the previously deprecated :meth:`Series.valid`; use :meth:`Series.dropna` instead (:issue:`18800`) +- Removed the previously properties :attr:`DataFrame.is_copy`, :attr:`Series.is_copy` (:issue:`18812`) +- Removed the previously deprecated :meth:`DataFrame.get_ftype_counts`, :meth:`Series.get_ftype_counts` (:issue:`18243`) +- Removed the previously deprecated :meth:`Index.get_duplicated`, use ``idx[idx.duplicated()].unique()`` instead (:issue:`20239`) +- Removed the previously deprecated :meth:`Series.clip_upper`, :meth:`Series.clip_lower`, :meth:`DataFrame.clip_upper`, :meth:`DataFrame.clip_lower` (:issue:`24203`) - Removed previously deprecated "order" argument from :func:`factorize` (:issue:`19751`) - Removed previously deprecated "v" argument from :meth:`FrozenNDarray.searchsorted`, use "value" instead (:issue:`22672`) - :func:`read_stata` and :meth:`DataFrame.to_stata` no longer supports the "encoding" argument (:issue:`21400`) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 6fbe95fa973cbf..7f83bb9e69f7af 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -172,16 +172,7 @@ class NDFrame(PandasObject, SelectionMixin): _internal_names_set = set(_internal_names) # type: Set[str] _accessors = set() # type: Set[str] _deprecations = frozenset( - [ - "clip_lower", - "clip_upper", - "get_dtype_counts", - "get_ftype_counts", - "get_values", - "is_copy", - "ftypes", - "ix", - ] + ["get_dtype_counts", "get_values", "ftypes", "ix"] ) # type: FrozenSet[str] _metadata = [] # type: List[str] _is_copy = None @@ -252,29 +243,6 @@ def attrs(self) -> Dict[Optional[Hashable], Any]: def attrs(self, value: Mapping[Optional[Hashable], Any]) -> None: self._attrs = dict(value) - @property - def is_copy(self): - """ - Return the copy. - """ - warnings.warn( - "Attribute 'is_copy' is deprecated and will be removed " - "in a future version.", - FutureWarning, - stacklevel=2, - ) - return self._is_copy - - @is_copy.setter - def is_copy(self, msg): - warnings.warn( - "Attribute 'is_copy' is deprecated and will be removed " - "in a future version.", - FutureWarning, - stacklevel=2, - ) - self._is_copy = msg - def _validate_dtype(self, dtype): """ validate the passed dtype """ @@ -5595,49 +5563,6 @@ def get_dtype_counts(self): return Series(self._data.get_dtype_counts()) - def get_ftype_counts(self): - """ - Return counts of unique ftypes in this object. - - .. deprecated:: 0.23.0 - - Returns - ------- - dtype : Series - Series with the count of columns with each type and - sparsity (dense/sparse). - - See Also - -------- - ftypes : Return ftypes (indication of sparse/dense and dtype) in - this object. - - Examples - -------- - >>> a = [['a', 1, 1.0], ['b', 2, 2.0], ['c', 3, 3.0]] - >>> df = pd.DataFrame(a, columns=['str', 'int', 'float']) - >>> df - str int float - 0 a 1 1.0 - 1 b 2 2.0 - 2 c 3 3.0 - - >>> df.get_ftype_counts() # doctest: +SKIP - float64:dense 1 - int64:dense 1 - object:dense 1 - dtype: int64 - """ - warnings.warn( - "get_ftype_counts is deprecated and will be removed in a future version", - FutureWarning, - stacklevel=2, - ) - - from pandas import Series - - return Series(self._data.get_ftype_counts()) - @property def dtypes(self): """ @@ -7526,208 +7451,6 @@ def clip(self, lower=None, upper=None, axis=None, inplace=False, *args, **kwargs return result - def clip_upper(self, threshold, axis=None, inplace=False): - """ - Trim values above a given threshold. - - .. deprecated:: 0.24.0 - Use clip(upper=threshold) instead. - - Elements above the `threshold` will be changed to match the - `threshold` value(s). Threshold can be a single value or an array, - in the latter case it performs the truncation element-wise. - - Parameters - ---------- - threshold : numeric or array-like - Maximum value allowed. All values above threshold will be set to - this value. - - * float : every value is compared to `threshold`. - * array-like : The shape of `threshold` should match the object - it's compared to. When `self` is a Series, `threshold` should be - the length. When `self` is a DataFrame, `threshold` should 2-D - and the same shape as `self` for ``axis=None``, or 1-D and the - same length as the axis being compared. - - axis : {0 or 'index', 1 or 'columns'}, default 0 - Align object with `threshold` along the given axis. - inplace : bool, default False - Whether to perform the operation in place on the data. - - .. versionadded:: 0.21.0 - - Returns - ------- - Series or DataFrame - Original data with values trimmed. - - See Also - -------- - Series.clip : General purpose method to trim Series values to given - threshold(s). - DataFrame.clip : General purpose method to trim DataFrame values to - given threshold(s). - - Examples - -------- - >>> s = pd.Series([1, 2, 3, 4, 5]) - >>> s - 0 1 - 1 2 - 2 3 - 3 4 - 4 5 - dtype: int64 - - >>> s.clip(upper=3) - 0 1 - 1 2 - 2 3 - 3 3 - 4 3 - dtype: int64 - - >>> elemwise_thresholds = [5, 4, 3, 2, 1] - >>> elemwise_thresholds - [5, 4, 3, 2, 1] - - >>> s.clip(upper=elemwise_thresholds) - 0 1 - 1 2 - 2 3 - 3 2 - 4 1 - dtype: int64 - """ - warnings.warn( - "clip_upper(threshold) is deprecated, use clip(upper=threshold) instead", - FutureWarning, - stacklevel=2, - ) - return self._clip_with_one_bound( - threshold, method=self.le, axis=axis, inplace=inplace - ) - - def clip_lower(self, threshold, axis=None, inplace=False): - """ - Trim values below a given threshold. - - .. deprecated:: 0.24.0 - Use clip(lower=threshold) instead. - - Elements below the `threshold` will be changed to match the - `threshold` value(s). Threshold can be a single value or an array, - in the latter case it performs the truncation element-wise. - - Parameters - ---------- - threshold : numeric or array-like - Minimum value allowed. All values below threshold will be set to - this value. - - * float : every value is compared to `threshold`. - * array-like : The shape of `threshold` should match the object - it's compared to. When `self` is a Series, `threshold` should be - the length. When `self` is a DataFrame, `threshold` should 2-D - and the same shape as `self` for ``axis=None``, or 1-D and the - same length as the axis being compared. - - axis : {0 or 'index', 1 or 'columns'}, default 0 - Align `self` with `threshold` along the given axis. - - inplace : bool, default False - Whether to perform the operation in place on the data. - - .. versionadded:: 0.21.0 - - Returns - ------- - Series or DataFrame - Original data with values trimmed. - - See Also - -------- - Series.clip : General purpose method to trim Series values to given - threshold(s). - DataFrame.clip : General purpose method to trim DataFrame values to - given threshold(s). - - Examples - -------- - - Series single threshold clipping: - - >>> s = pd.Series([5, 6, 7, 8, 9]) - >>> s.clip(lower=8) - 0 8 - 1 8 - 2 8 - 3 8 - 4 9 - dtype: int64 - - Series clipping element-wise using an array of thresholds. `threshold` - should be the same length as the Series. - - >>> elemwise_thresholds = [4, 8, 7, 2, 5] - >>> s.clip(lower=elemwise_thresholds) - 0 5 - 1 8 - 2 7 - 3 8 - 4 9 - dtype: int64 - - DataFrames can be compared to a scalar. - - >>> df = pd.DataFrame({"A": [1, 3, 5], "B": [2, 4, 6]}) - >>> df - A B - 0 1 2 - 1 3 4 - 2 5 6 - - >>> df.clip(lower=3) - A B - 0 3 3 - 1 3 4 - 2 5 6 - - Or to an array of values. By default, `threshold` should be the same - shape as the DataFrame. - - >>> df.clip(lower=np.array([[3, 4], [2, 2], [6, 2]])) - A B - 0 3 4 - 1 3 4 - 2 6 6 - - Control how `threshold` is broadcast with `axis`. In this case - `threshold` should be the same length as the axis specified by - `axis`. - - >>> df.clip(lower=[3, 3, 5], axis='index') - A B - 0 3 3 - 1 3 4 - 2 5 6 - - >>> df.clip(lower=[4, 5], axis='columns') - A B - 0 4 5 - 1 4 5 - 2 5 6 - """ - warnings.warn( - "clip_lower(threshold) is deprecated, use clip(lower=threshold) instead", - FutureWarning, - stacklevel=2, - ) - return self._clip_with_one_bound( - threshold, method=self.ge, axis=axis, inplace=inplace - ) - def groupby( self, by=None, diff --git a/pandas/core/internals/managers.py b/pandas/core/internals/managers.py index c36dd9463c61d2..d53fbe2e60e9a5 100644 --- a/pandas/core/internals/managers.py +++ b/pandas/core/internals/managers.py @@ -79,7 +79,6 @@ class BlockManager(PandasObject): copy(deep=True) get_dtype_counts - get_ftype_counts get_dtypes get_ftypes @@ -246,9 +245,6 @@ def _get_counts(self, f): def get_dtype_counts(self): return self._get_counts(lambda b: b.dtype.name) - def get_ftype_counts(self): - return self._get_counts(lambda b: b.ftype) - def get_dtypes(self): dtypes = np.array([blk.dtype for blk in self.blocks]) return algos.take_1d(dtypes, self._blknos, allow_fill=False) @@ -1555,9 +1551,6 @@ def ftype(self): def get_dtype_counts(self): return {self.dtype.name: 1} - def get_ftype_counts(self): - return {self.ftype: 1} - def get_dtypes(self): return np.array([self._block.dtype]) diff --git a/pandas/core/series.py b/pandas/core/series.py index c10871d04ef3e2..a950b4496baa71 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4615,26 +4615,6 @@ def dropna(self, axis=0, inplace=False, how=None): else: return self.copy() - def valid(self, inplace=False, **kwargs): - """ - Return Series without null values. - - .. deprecated:: 0.23.0 - Use :meth:`Series.dropna` instead. - - Returns - ------- - Series - Series without null values. - """ - warnings.warn( - "Method .valid will be removed in a future version. " - "Use .dropna instead.", - FutureWarning, - stacklevel=2, - ) - return self.dropna(inplace=inplace, **kwargs) - # ---------------------------------------------------------------------- # Time series-oriented methods diff --git a/pandas/tests/frame/test_analytics.py b/pandas/tests/frame/test_analytics.py index 9cc9c5dc697b68..005ca8d95182e1 100644 --- a/pandas/tests/frame/test_analytics.py +++ b/pandas/tests/frame/test_analytics.py @@ -2279,14 +2279,6 @@ def test_clip(self, float_frame): median = float_frame.median().median() original = float_frame.copy() - with tm.assert_produces_warning(FutureWarning): - capped = float_frame.clip_upper(median) - assert not (capped.values > median).any() - - with tm.assert_produces_warning(FutureWarning): - floored = float_frame.clip_lower(median) - assert not (floored.values < median).any() - double = float_frame.clip(upper=median, lower=median) assert not (double.values != median).any() @@ -2298,16 +2290,6 @@ def test_inplace_clip(self, float_frame): median = float_frame.median().median() frame_copy = float_frame.copy() - with tm.assert_produces_warning(FutureWarning): - frame_copy.clip_upper(median, inplace=True) - assert not (frame_copy.values > median).any() - frame_copy = float_frame.copy() - - with tm.assert_produces_warning(FutureWarning): - frame_copy.clip_lower(median, inplace=True) - assert not (frame_copy.values < median).any() - frame_copy = float_frame.copy() - frame_copy.clip(upper=median, lower=median, inplace=True) assert not (frame_copy.values != median).any() @@ -2759,8 +2741,7 @@ def test_series_broadcasting(self): s_nan = Series([np.nan, np.nan, 1]) with tm.assert_produces_warning(None): - with tm.assert_produces_warning(FutureWarning): - df_nan.clip_lower(s, axis=0) + df_nan.clip(lower=s, axis=0) for op in ["lt", "le", "gt", "ge", "eq", "ne"]: getattr(df, op)(s_nan, axis=0) diff --git a/pandas/tests/generic/test_series.py b/pandas/tests/generic/test_series.py index ae452e6faef012..096a5aa99bd80b 100644 --- a/pandas/tests/generic/test_series.py +++ b/pandas/tests/generic/test_series.py @@ -243,11 +243,6 @@ def test_to_xarray(self): assert isinstance(result, DataArray) tm.assert_series_equal(result.to_series(), s) - def test_valid_deprecated(self): - # GH18800 - with tm.assert_produces_warning(FutureWarning): - pd.Series([]).valid() - @pytest.mark.parametrize( "s", [ diff --git a/pandas/tests/indexing/test_chaining_and_caching.py b/pandas/tests/indexing/test_chaining_and_caching.py index 274b72b0561a93..6e26d407ab0ec1 100644 --- a/pandas/tests/indexing/test_chaining_and_caching.py +++ b/pandas/tests/indexing/test_chaining_and_caching.py @@ -393,14 +393,3 @@ def test_cache_updating(self): tm.assert_frame_equal(df, expected) expected = Series([0, 0, 0, 2, 0], name="f") tm.assert_series_equal(df.f, expected) - - def test_deprecate_is_copy(self): - # GH18801 - df = DataFrame({"A": [1, 2, 3]}) - with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): - # getter - df.is_copy - - with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): - # setter - df.is_copy = "test deprecated is_copy" diff --git a/pandas/tests/series/test_analytics.py b/pandas/tests/series/test_analytics.py index 79eaeaf051d2ef..e25c4456147f77 100644 --- a/pandas/tests/series/test_analytics.py +++ b/pandas/tests/series/test_analytics.py @@ -655,11 +655,6 @@ def test_matmul(self): def test_clip(self, datetime_series): val = datetime_series.median() - with tm.assert_produces_warning(FutureWarning): - assert datetime_series.clip_lower(val).min() == val - with tm.assert_produces_warning(FutureWarning): - assert datetime_series.clip_upper(val).max() == val - assert datetime_series.clip(lower=val).min() == val assert datetime_series.clip(upper=val).max() == val @@ -678,10 +673,8 @@ def test_clip_types_and_nulls(self): for s in sers: thresh = s[2] - with tm.assert_produces_warning(FutureWarning): - lower = s.clip_lower(thresh) - with tm.assert_produces_warning(FutureWarning): - upper = s.clip_upper(thresh) + lower = s.clip(lower=thresh) + upper = s.clip(upper=thresh) assert lower[notna(lower)].min() == thresh assert upper[notna(upper)].max() == thresh assert list(isna(s)) == list(isna(lower)) @@ -703,12 +696,6 @@ def test_clip_against_series(self): # GH #6966 s = Series([1.0, 1.0, 4.0]) - threshold = Series([1.0, 2.0, 3.0]) - - with tm.assert_produces_warning(FutureWarning): - tm.assert_series_equal(s.clip_lower(threshold), Series([1.0, 2.0, 4.0])) - with tm.assert_produces_warning(FutureWarning): - tm.assert_series_equal(s.clip_upper(threshold), Series([1.0, 1.0, 3.0])) lower = Series([1.0, 2.0, 3.0]) upper = Series([1.5, 2.5, 3.5]) diff --git a/pandas/tests/series/test_dtypes.py b/pandas/tests/series/test_dtypes.py index e1ace952f722da..ec0318b2af13a8 100644 --- a/pandas/tests/series/test_dtypes.py +++ b/pandas/tests/series/test_dtypes.py @@ -56,11 +56,6 @@ def test_dtype(self, datetime_series): # GH 26705 - Assert .ftypes is deprecated with tm.assert_produces_warning(FutureWarning): assert datetime_series.ftypes == "float64:dense" - # GH18243 - Assert .get_ftype_counts is deprecated - with tm.assert_produces_warning(FutureWarning): - tm.assert_series_equal( - datetime_series.get_ftype_counts(), Series(1, ["float64:dense"]) - ) @pytest.mark.parametrize("value", [np.nan, np.inf]) @pytest.mark.parametrize("dtype", [np.int32, np.int64])