Skip to content

Commit 9eea1ef

Browse files
jbrockmendelproost
authored andcommitted
DEPR: remove Series.valid, is_copy, get_ftype_counts, Index.get_duplicate, Series.clip_upper, clip_lower (pandas-dev#29724)
1 parent 06164dd commit 9eea1ef

File tree

11 files changed

+9
-368
lines changed

11 files changed

+9
-368
lines changed

doc/source/reference/frame.rst

-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ Attributes and underlying data
3030
DataFrame.dtypes
3131
DataFrame.ftypes
3232
DataFrame.get_dtype_counts
33-
DataFrame.get_ftype_counts
3433
DataFrame.select_dtypes
3534
DataFrame.values
3635
DataFrame.get_values
@@ -40,7 +39,6 @@ Attributes and underlying data
4039
DataFrame.shape
4140
DataFrame.memory_usage
4241
DataFrame.empty
43-
DataFrame.is_copy
4442

4543
Conversion
4644
~~~~~~~~~~
@@ -142,8 +140,6 @@ Computations / descriptive stats
142140
DataFrame.all
143141
DataFrame.any
144142
DataFrame.clip
145-
DataFrame.clip_lower
146-
DataFrame.clip_upper
147143
DataFrame.compound
148144
DataFrame.corr
149145
DataFrame.corrwith

doc/source/reference/series.rst

-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ Attributes
4545
Series.dtypes
4646
Series.ftypes
4747
Series.data
48-
Series.is_copy
4948
Series.name
5049
Series.put
5150

@@ -148,8 +147,6 @@ Computations / descriptive stats
148147
Series.autocorr
149148
Series.between
150149
Series.clip
151-
Series.clip_lower
152-
Series.clip_upper
153150
Series.corr
154151
Series.count
155152
Series.cov

doc/source/whatsnew/v1.0.0.rst

+5
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,11 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
333333
- Removed previously deprecated "nthreads" argument from :func:`read_feather`, use "use_threads" instead (:issue:`23053`)
334334
- Removed :meth:`Index.is_lexsorted_for_tuple` (:issue:`29305`)
335335
- Removed support for nexted renaming in :meth:`DataFrame.aggregate`, :meth:`Series.aggregate`, :meth:`DataFrameGroupBy.aggregate`, :meth:`SeriesGroupBy.aggregate`, :meth:`Rolling.aggregate` (:issue:`29608`)
336+
- Removed the previously deprecated :meth:`Series.valid`; use :meth:`Series.dropna` instead (:issue:`18800`)
337+
- Removed the previously properties :attr:`DataFrame.is_copy`, :attr:`Series.is_copy` (:issue:`18812`)
338+
- Removed the previously deprecated :meth:`DataFrame.get_ftype_counts`, :meth:`Series.get_ftype_counts` (:issue:`18243`)
339+
- Removed the previously deprecated :meth:`Index.get_duplicated`, use ``idx[idx.duplicated()].unique()`` instead (:issue:`20239`)
340+
- Removed the previously deprecated :meth:`Series.clip_upper`, :meth:`Series.clip_lower`, :meth:`DataFrame.clip_upper`, :meth:`DataFrame.clip_lower` (:issue:`24203`)
336341
- Removed previously deprecated "order" argument from :func:`factorize` (:issue:`19751`)
337342
- Removed previously deprecated "v" argument from :meth:`FrozenNDarray.searchsorted`, use "value" instead (:issue:`22672`)
338343
- :func:`read_stata` and :meth:`DataFrame.to_stata` no longer supports the "encoding" argument (:issue:`21400`)

pandas/core/generic.py

+1-278
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,7 @@ class NDFrame(PandasObject, SelectionMixin):
172172
_internal_names_set = set(_internal_names) # type: Set[str]
173173
_accessors = set() # type: Set[str]
174174
_deprecations = frozenset(
175-
[
176-
"clip_lower",
177-
"clip_upper",
178-
"get_dtype_counts",
179-
"get_ftype_counts",
180-
"get_values",
181-
"is_copy",
182-
"ftypes",
183-
"ix",
184-
]
175+
["get_dtype_counts", "get_values", "ftypes", "ix"]
185176
) # type: FrozenSet[str]
186177
_metadata = [] # type: List[str]
187178
_is_copy = None
@@ -252,29 +243,6 @@ def attrs(self) -> Dict[Optional[Hashable], Any]:
252243
def attrs(self, value: Mapping[Optional[Hashable], Any]) -> None:
253244
self._attrs = dict(value)
254245

255-
@property
256-
def is_copy(self):
257-
"""
258-
Return the copy.
259-
"""
260-
warnings.warn(
261-
"Attribute 'is_copy' is deprecated and will be removed "
262-
"in a future version.",
263-
FutureWarning,
264-
stacklevel=2,
265-
)
266-
return self._is_copy
267-
268-
@is_copy.setter
269-
def is_copy(self, msg):
270-
warnings.warn(
271-
"Attribute 'is_copy' is deprecated and will be removed "
272-
"in a future version.",
273-
FutureWarning,
274-
stacklevel=2,
275-
)
276-
self._is_copy = msg
277-
278246
def _validate_dtype(self, dtype):
279247
""" validate the passed dtype """
280248

@@ -5595,49 +5563,6 @@ def get_dtype_counts(self):
55955563

55965564
return Series(self._data.get_dtype_counts())
55975565

5598-
def get_ftype_counts(self):
5599-
"""
5600-
Return counts of unique ftypes in this object.
5601-
5602-
.. deprecated:: 0.23.0
5603-
5604-
Returns
5605-
-------
5606-
dtype : Series
5607-
Series with the count of columns with each type and
5608-
sparsity (dense/sparse).
5609-
5610-
See Also
5611-
--------
5612-
ftypes : Return ftypes (indication of sparse/dense and dtype) in
5613-
this object.
5614-
5615-
Examples
5616-
--------
5617-
>>> a = [['a', 1, 1.0], ['b', 2, 2.0], ['c', 3, 3.0]]
5618-
>>> df = pd.DataFrame(a, columns=['str', 'int', 'float'])
5619-
>>> df
5620-
str int float
5621-
0 a 1 1.0
5622-
1 b 2 2.0
5623-
2 c 3 3.0
5624-
5625-
>>> df.get_ftype_counts() # doctest: +SKIP
5626-
float64:dense 1
5627-
int64:dense 1
5628-
object:dense 1
5629-
dtype: int64
5630-
"""
5631-
warnings.warn(
5632-
"get_ftype_counts is deprecated and will be removed in a future version",
5633-
FutureWarning,
5634-
stacklevel=2,
5635-
)
5636-
5637-
from pandas import Series
5638-
5639-
return Series(self._data.get_ftype_counts())
5640-
56415566
@property
56425567
def dtypes(self):
56435568
"""
@@ -7526,208 +7451,6 @@ def clip(self, lower=None, upper=None, axis=None, inplace=False, *args, **kwargs
75267451

75277452
return result
75287453

7529-
def clip_upper(self, threshold, axis=None, inplace=False):
7530-
"""
7531-
Trim values above a given threshold.
7532-
7533-
.. deprecated:: 0.24.0
7534-
Use clip(upper=threshold) instead.
7535-
7536-
Elements above the `threshold` will be changed to match the
7537-
`threshold` value(s). Threshold can be a single value or an array,
7538-
in the latter case it performs the truncation element-wise.
7539-
7540-
Parameters
7541-
----------
7542-
threshold : numeric or array-like
7543-
Maximum value allowed. All values above threshold will be set to
7544-
this value.
7545-
7546-
* float : every value is compared to `threshold`.
7547-
* array-like : The shape of `threshold` should match the object
7548-
it's compared to. When `self` is a Series, `threshold` should be
7549-
the length. When `self` is a DataFrame, `threshold` should 2-D
7550-
and the same shape as `self` for ``axis=None``, or 1-D and the
7551-
same length as the axis being compared.
7552-
7553-
axis : {0 or 'index', 1 or 'columns'}, default 0
7554-
Align object with `threshold` along the given axis.
7555-
inplace : bool, default False
7556-
Whether to perform the operation in place on the data.
7557-
7558-
.. versionadded:: 0.21.0
7559-
7560-
Returns
7561-
-------
7562-
Series or DataFrame
7563-
Original data with values trimmed.
7564-
7565-
See Also
7566-
--------
7567-
Series.clip : General purpose method to trim Series values to given
7568-
threshold(s).
7569-
DataFrame.clip : General purpose method to trim DataFrame values to
7570-
given threshold(s).
7571-
7572-
Examples
7573-
--------
7574-
>>> s = pd.Series([1, 2, 3, 4, 5])
7575-
>>> s
7576-
0 1
7577-
1 2
7578-
2 3
7579-
3 4
7580-
4 5
7581-
dtype: int64
7582-
7583-
>>> s.clip(upper=3)
7584-
0 1
7585-
1 2
7586-
2 3
7587-
3 3
7588-
4 3
7589-
dtype: int64
7590-
7591-
>>> elemwise_thresholds = [5, 4, 3, 2, 1]
7592-
>>> elemwise_thresholds
7593-
[5, 4, 3, 2, 1]
7594-
7595-
>>> s.clip(upper=elemwise_thresholds)
7596-
0 1
7597-
1 2
7598-
2 3
7599-
3 2
7600-
4 1
7601-
dtype: int64
7602-
"""
7603-
warnings.warn(
7604-
"clip_upper(threshold) is deprecated, use clip(upper=threshold) instead",
7605-
FutureWarning,
7606-
stacklevel=2,
7607-
)
7608-
return self._clip_with_one_bound(
7609-
threshold, method=self.le, axis=axis, inplace=inplace
7610-
)
7611-
7612-
def clip_lower(self, threshold, axis=None, inplace=False):
7613-
"""
7614-
Trim values below a given threshold.
7615-
7616-
.. deprecated:: 0.24.0
7617-
Use clip(lower=threshold) instead.
7618-
7619-
Elements below the `threshold` will be changed to match the
7620-
`threshold` value(s). Threshold can be a single value or an array,
7621-
in the latter case it performs the truncation element-wise.
7622-
7623-
Parameters
7624-
----------
7625-
threshold : numeric or array-like
7626-
Minimum value allowed. All values below threshold will be set to
7627-
this value.
7628-
7629-
* float : every value is compared to `threshold`.
7630-
* array-like : The shape of `threshold` should match the object
7631-
it's compared to. When `self` is a Series, `threshold` should be
7632-
the length. When `self` is a DataFrame, `threshold` should 2-D
7633-
and the same shape as `self` for ``axis=None``, or 1-D and the
7634-
same length as the axis being compared.
7635-
7636-
axis : {0 or 'index', 1 or 'columns'}, default 0
7637-
Align `self` with `threshold` along the given axis.
7638-
7639-
inplace : bool, default False
7640-
Whether to perform the operation in place on the data.
7641-
7642-
.. versionadded:: 0.21.0
7643-
7644-
Returns
7645-
-------
7646-
Series or DataFrame
7647-
Original data with values trimmed.
7648-
7649-
See Also
7650-
--------
7651-
Series.clip : General purpose method to trim Series values to given
7652-
threshold(s).
7653-
DataFrame.clip : General purpose method to trim DataFrame values to
7654-
given threshold(s).
7655-
7656-
Examples
7657-
--------
7658-
7659-
Series single threshold clipping:
7660-
7661-
>>> s = pd.Series([5, 6, 7, 8, 9])
7662-
>>> s.clip(lower=8)
7663-
0 8
7664-
1 8
7665-
2 8
7666-
3 8
7667-
4 9
7668-
dtype: int64
7669-
7670-
Series clipping element-wise using an array of thresholds. `threshold`
7671-
should be the same length as the Series.
7672-
7673-
>>> elemwise_thresholds = [4, 8, 7, 2, 5]
7674-
>>> s.clip(lower=elemwise_thresholds)
7675-
0 5
7676-
1 8
7677-
2 7
7678-
3 8
7679-
4 9
7680-
dtype: int64
7681-
7682-
DataFrames can be compared to a scalar.
7683-
7684-
>>> df = pd.DataFrame({"A": [1, 3, 5], "B": [2, 4, 6]})
7685-
>>> df
7686-
A B
7687-
0 1 2
7688-
1 3 4
7689-
2 5 6
7690-
7691-
>>> df.clip(lower=3)
7692-
A B
7693-
0 3 3
7694-
1 3 4
7695-
2 5 6
7696-
7697-
Or to an array of values. By default, `threshold` should be the same
7698-
shape as the DataFrame.
7699-
7700-
>>> df.clip(lower=np.array([[3, 4], [2, 2], [6, 2]]))
7701-
A B
7702-
0 3 4
7703-
1 3 4
7704-
2 6 6
7705-
7706-
Control how `threshold` is broadcast with `axis`. In this case
7707-
`threshold` should be the same length as the axis specified by
7708-
`axis`.
7709-
7710-
>>> df.clip(lower=[3, 3, 5], axis='index')
7711-
A B
7712-
0 3 3
7713-
1 3 4
7714-
2 5 6
7715-
7716-
>>> df.clip(lower=[4, 5], axis='columns')
7717-
A B
7718-
0 4 5
7719-
1 4 5
7720-
2 5 6
7721-
"""
7722-
warnings.warn(
7723-
"clip_lower(threshold) is deprecated, use clip(lower=threshold) instead",
7724-
FutureWarning,
7725-
stacklevel=2,
7726-
)
7727-
return self._clip_with_one_bound(
7728-
threshold, method=self.ge, axis=axis, inplace=inplace
7729-
)
7730-
77317454
def groupby(
77327455
self,
77337456
by=None,

pandas/core/internals/managers.py

-7
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ class BlockManager(PandasObject):
7979
copy(deep=True)
8080
8181
get_dtype_counts
82-
get_ftype_counts
8382
get_dtypes
8483
get_ftypes
8584
@@ -246,9 +245,6 @@ def _get_counts(self, f):
246245
def get_dtype_counts(self):
247246
return self._get_counts(lambda b: b.dtype.name)
248247

249-
def get_ftype_counts(self):
250-
return self._get_counts(lambda b: b.ftype)
251-
252248
def get_dtypes(self):
253249
dtypes = np.array([blk.dtype for blk in self.blocks])
254250
return algos.take_1d(dtypes, self._blknos, allow_fill=False)
@@ -1555,9 +1551,6 @@ def ftype(self):
15551551
def get_dtype_counts(self):
15561552
return {self.dtype.name: 1}
15571553

1558-
def get_ftype_counts(self):
1559-
return {self.ftype: 1}
1560-
15611554
def get_dtypes(self):
15621555
return np.array([self._block.dtype])
15631556

0 commit comments

Comments
 (0)