Skip to content

Commit

Permalink
DEPR: remove Series.valid, is_copy, get_ftype_counts, Index.get_dupli…
Browse files Browse the repository at this point in the history
…cate, Series.clip_upper, clip_lower (#29724)
  • Loading branch information
jbrockmendel authored and jorisvandenbossche committed Nov 21, 2019
1 parent 4090d43 commit f4d1a84
Show file tree
Hide file tree
Showing 11 changed files with 9 additions and 368 deletions.
4 changes: 0 additions & 4 deletions doc/source/reference/frame.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -40,7 +39,6 @@ Attributes and underlying data
DataFrame.shape
DataFrame.memory_usage
DataFrame.empty
DataFrame.is_copy

Conversion
~~~~~~~~~~
Expand Down Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions doc/source/reference/series.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ Attributes
Series.dtypes
Series.ftypes
Series.data
Series.is_copy
Series.name
Series.put

Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions doc/source/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down
279 changes: 1 addition & 278 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 """

Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 0 additions & 7 deletions pandas/core/internals/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ class BlockManager(PandasObject):
copy(deep=True)
get_dtype_counts
get_ftype_counts
get_dtypes
get_ftypes
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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])

Expand Down
Loading

0 comments on commit f4d1a84

Please sign in to comment.