Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLN: Remove pandas.value_counts, Index.format, is_interval, is_period #57296

Merged
merged 8 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions asv_bench/benchmarks/strftime.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,6 @@ def time_frame_period_formatting_default(self, nobs, freq):
def time_frame_period_formatting_default_explicit(self, nobs, freq):
self.data["p"].dt.strftime(date_format=self.default_fmt)

def time_frame_period_formatting_index_default(self, nobs, freq):
self.data.index.format()

def time_frame_period_formatting_index_default_explicit(self, nobs, freq):
self.data.index.format(self.default_fmt)

def time_frame_period_formatting_custom(self, nobs, freq):
self.data["p"].dt.strftime(date_format="%Y-%m-%d --- %H:%M:%S")

Expand Down
1 change: 0 additions & 1 deletion doc/redirects.csv
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ generated/pandas.api.types.is_int64_dtype,../reference/api/pandas.api.types.is_i
generated/pandas.api.types.is_integer_dtype,../reference/api/pandas.api.types.is_integer_dtype
generated/pandas.api.types.is_integer,../reference/api/pandas.api.types.is_integer
generated/pandas.api.types.is_interval_dtype,../reference/api/pandas.api.types.is_interval_dtype
generated/pandas.api.types.is_interval,../reference/api/pandas.api.types.is_interval
generated/pandas.api.types.is_iterator,../reference/api/pandas.api.types.is_iterator
generated/pandas.api.types.is_list_like,../reference/api/pandas.api.types.is_list_like
generated/pandas.api.types.is_named_tuple,../reference/api/pandas.api.types.is_named_tuple
Expand Down
1 change: 0 additions & 1 deletion doc/source/reference/arrays.rst
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,6 @@ Scalar introspection
api.types.is_float
api.types.is_hashable
api.types.is_integer
api.types.is_interval
api.types.is_number
api.types.is_re
api.types.is_re_compilable
Expand Down
3 changes: 3 additions & 0 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,12 @@ Removal of prior version deprecations/changes
- All arguments except the first ``path``-like argument in IO writers are now keyword only (:issue:`54229`)
- Removed ``DataFrameGroupBy.grouper`` and ``SeriesGroupBy.grouper`` (:issue:`56521`)
- Removed ``DataFrameGroupby.fillna`` and ``SeriesGroupBy.fillna``` (:issue:`55719`)
- Removed ``Index.format``, use :meth:`Index.astype` with ``str`` or :meth:`Index.map` with a ``formatter`` function instead (:issue:`55439`)
- Removed ``axis`` argument from :meth:`DataFrame.groupby`, :meth:`Series.groupby`, :meth:`DataFrame.rolling`, :meth:`Series.rolling`, :meth:`DataFrame.resample`, and :meth:`Series.resample` (:issue:`51203`)
- Removed ``axis`` argument from all groupby operations (:issue:`50405`)
- Removed ``pandas.api.types.is_interval`` and ``pandas.api.types.is_period``, use ``isinstance(obj, pd.Interval)`` and ``isinstance(obj, pd.Period)`` instead (:issue:`55264`)
- Removed ``pandas.io.sql.execute`` (:issue:`50185`)
- Removed ``pandas.value_counts``, use :meth:`Series.value_counts` instead (:issue:`53493`)
- Removed ``read_gbq`` and ``DataFrame.to_gbq``. Use ``pandas_gbq.read_gbq`` and ``pandas_gbq.to_gbq`` instead https://pandas-gbq.readthedocs.io/en/latest/api.html (:issue:`55525`)
- Removed deprecated argument ``obj`` in :meth:`.DataFrameGroupBy.get_group` and :meth:`.SeriesGroupBy.get_group` (:issue:`53545`)
- Removed the ``ArrayManager`` (:issue:`55043`)
Expand Down
2 changes: 0 additions & 2 deletions pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
Grouper,
factorize,
unique,
value_counts,
NamedAgg,
array,
Categorical,
Expand Down Expand Up @@ -378,6 +377,5 @@
"to_timedelta",
"tseries",
"unique",
"value_counts",
"wide_to_long",
]
4 changes: 0 additions & 4 deletions pandas/_libs/lib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ from typing import (

import numpy as np

from pandas._libs.interval import Interval
from pandas._libs.tslibs import Period
from pandas._typing import (
ArrayLike,
DtypeObj,
Expand Down Expand Up @@ -44,8 +42,6 @@ def is_iterator(obj: object) -> bool: ...
def is_scalar(val: object) -> bool: ...
def is_list_like(obj: object, allow_sets: bool = ...) -> bool: ...
def is_pyarrow_array(obj: object) -> bool: ...
def is_period(val: object) -> TypeGuard[Period]: ...
def is_interval(obj: object) -> TypeGuard[Interval]: ...
def is_decimal(obj: object) -> TypeGuard[Decimal]: ...
def is_complex(obj: object) -> TypeGuard[complex]: ...
def is_bool(obj: object) -> TypeGuard[bool | np.bool_]: ...
Expand Down
37 changes: 0 additions & 37 deletions pandas/_libs/lib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1164,43 +1164,6 @@ cpdef bint is_decimal(object obj):
return isinstance(obj, Decimal)


cpdef bint is_interval(object obj):
import warnings

from pandas.util._exceptions import find_stack_level

warnings.warn(
# GH#55264
"is_interval is deprecated and will be removed in a future version. "
"Use isinstance(obj, pd.Interval) instead.",
FutureWarning,
stacklevel=find_stack_level(),
)
return getattr(obj, "_typ", "_typ") == "interval"


def is_period(val: object) -> bool:
"""
Return True if given object is Period.

Returns
-------
bool
"""
import warnings

from pandas.util._exceptions import find_stack_level

warnings.warn(
# GH#55264
"is_period is deprecated and will be removed in a future version. "
"Use isinstance(obj, pd.Period) instead.",
FutureWarning,
stacklevel=find_stack_level(),
)
return is_period_object(val)


def is_list_like(obj: object, allow_sets: bool = True) -> bool:
"""
Check if the object is list-like.
Expand Down
47 changes: 0 additions & 47 deletions pandas/core/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,53 +818,6 @@ def factorize(
return codes, uniques


def value_counts(
values,
sort: bool = True,
ascending: bool = False,
normalize: bool = False,
bins=None,
dropna: bool = True,
) -> Series:
"""
Compute a histogram of the counts of non-null values.

Parameters
----------
values : ndarray (1-d)
sort : bool, default True
Sort by values
ascending : bool, default False
Sort in ascending order
normalize: bool, default False
If True then compute a relative histogram
bins : integer, optional
Rather than count values, group them into half-open bins,
convenience for pd.cut, only works with numeric data
dropna : bool, default True
Don't include counts of NaN

Returns
-------
Series
"""
warnings.warn(
# GH#53493
"pandas.value_counts is deprecated and will be removed in a "
"future version. Use pd.Series(obj).value_counts() instead.",
FutureWarning,
stacklevel=find_stack_level(),
)
return value_counts_internal(
values,
sort=sort,
ascending=ascending,
normalize=normalize,
bins=bins,
dropna=dropna,
)


def value_counts_internal(
values,
sort: bool = True,
Expand Down
2 changes: 0 additions & 2 deletions pandas/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from pandas.core.algorithms import (
factorize,
unique,
value_counts,
)
from pandas.core.arrays import Categorical
from pandas.core.arrays.boolean import BooleanDtype
Expand Down Expand Up @@ -136,5 +135,4 @@
"UInt64Dtype",
"UInt8Dtype",
"unique",
"value_counts",
]
2 changes: 0 additions & 2 deletions pandas/core/dtypes/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
is_int64_dtype,
is_integer,
is_integer_dtype,
is_interval,
is_interval_dtype,
is_iterator,
is_list_like,
Expand Down Expand Up @@ -63,7 +62,6 @@
"is_int64_dtype",
"is_integer",
"is_integer_dtype",
"is_interval",
"is_interval_dtype",
"is_iterator",
"is_list_like",
Expand Down
2 changes: 0 additions & 2 deletions pandas/core/dtypes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
is_float,
is_hashable,
is_integer,
is_interval,
is_iterator,
is_list_like,
is_named_tuple,
Expand Down Expand Up @@ -1710,7 +1709,6 @@ def is_all_strings(value: ArrayLike) -> bool:
"is_float_dtype",
"is_int64_dtype",
"is_integer_dtype",
"is_interval",
"is_interval_dtype",
"is_iterator",
"is_named_tuple",
Expand Down
2 changes: 0 additions & 2 deletions pandas/core/dtypes/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@

is_decimal = lib.is_decimal

is_interval = lib.is_interval

is_list_like = lib.is_list_like

is_iterator = lib.is_iterator
Expand Down
30 changes: 0 additions & 30 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1394,36 +1394,6 @@ def _mpl_repr(self) -> np.ndarray:
return cast(np.ndarray, self.values)
return self.astype(object, copy=False)._values

def format(
self,
name: bool = False,
formatter: Callable | None = None,
na_rep: str_t = "NaN",
) -> list[str_t]:
"""
Render a string representation of the Index.
"""
warnings.warn(
# GH#55413
f"{type(self).__name__}.format is deprecated and will be removed "
"in a future version. Convert using index.astype(str) or "
"index.map(formatter) instead.",
FutureWarning,
stacklevel=find_stack_level(),
)
header = []
if name:
header.append(
pprint_thing(self.name, escape_chars=("\t", "\r", "\n"))
if self.name is not None
else ""
)

if formatter is not None:
return header + list(self.map(formatter))

return self._format_with_header(header=header, na_rep=na_rep)

_default_na_rep = "NaN"

@final
Expand Down
36 changes: 0 additions & 36 deletions pandas/core/indexes/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
from typing import (
TYPE_CHECKING,
Any,
Callable,
cast,
final,
)
import warnings

import numpy as np

Expand Down Expand Up @@ -43,7 +41,6 @@
cache_readonly,
doc,
)
from pandas.util._exceptions import find_stack_level

from pandas.core.dtypes.common import (
is_integer,
Expand Down Expand Up @@ -192,39 +189,6 @@ def _convert_tolerance(self, tolerance, target):
# Rendering Methods
_default_na_rep = "NaT"

def format(
self,
name: bool = False,
formatter: Callable | None = None,
na_rep: str = "NaT",
date_format: str | None = None,
) -> list[str]:
"""
Render a string representation of the Index.
"""
warnings.warn(
# GH#55413
f"{type(self).__name__}.format is deprecated and will be removed "
"in a future version. Convert using index.astype(str) or "
"index.map(formatter) instead.",
FutureWarning,
stacklevel=find_stack_level(),
)
header = []
if name:
header.append(
ibase.pprint_thing(self.name, escape_chars=("\t", "\r", "\n"))
if self.name is not None
else ""
)

if formatter is not None:
return header + list(self.map(formatter))

return self._format_with_header(
header=header, na_rep=na_rep, date_format=date_format
)

def _format_with_header(
self, *, header: list[str], na_rep: str, date_format: str | None = None
) -> list[str]:
Expand Down
Loading
Loading