Skip to content

CLN: Enforce deprecation of arg in Series.map #62104

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

Closed
Closed
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ Other Removals
- Enforced deprecation of :meth:`.DataFrameGroupBy.get_group` and :meth:`.SeriesGroupBy.get_group` allowing the ``name`` argument to be a non-tuple when grouping by a list of length 1 (:issue:`54155`)
- Enforced deprecation of :meth:`Series.interpolate` and :meth:`DataFrame.interpolate` for object-dtype (:issue:`57820`)
- Enforced deprecation of :meth:`offsets.Tick.delta`, use ``pd.Timedelta(obj)`` instead (:issue:`55498`)
- Enforced deprecation of ``arg`` argument in ``Series.map`` (:issue:`61264`)
- Enforced deprecation of ``axis=None`` acting the same as ``axis=0`` in the DataFrame reductions ``sum``, ``prod``, ``std``, ``var``, and ``sem``, passing ``axis=None`` will now reduce over both axes; this is particularly the case when doing e.g. ``numpy.sum(df)`` (:issue:`21597`)
- Enforced deprecation of ``core.internals`` member ``DatetimeTZBlock`` (:issue:`58467`)
- Enforced deprecation of ``date_parser`` in :func:`read_csv`, :func:`read_table`, :func:`read_fwf`, and :func:`read_excel` in favour of ``date_format`` (:issue:`50601`)
Expand Down
20 changes: 2 additions & 18 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@
doc,
set_module,
)
from pandas.util._exceptions import (
find_stack_level,
)
from pandas.util._validators import (
validate_ascending,
validate_bool_kwarg,
Expand Down Expand Up @@ -4328,7 +4325,7 @@ def unstack(

def map(
self,
func: Callable | Mapping | Series | None = None,
func: Callable | Mapping | Series,
na_action: Literal["ignore"] | None = None,
engine: Callable | None = None,
**kwargs,
Expand Down Expand Up @@ -4368,7 +4365,7 @@ def map(

**kwargs
Additional keyword arguments to pass as keywords arguments to
`arg`.
`func`.

.. versionadded:: 3.0.0

Expand Down Expand Up @@ -4432,19 +4429,6 @@ def map(
3 I am a rabbit
dtype: object
"""
if func is None:
if "arg" in kwargs:
# `.map(arg=my_func)`
func = kwargs.pop("arg")
warnings.warn(
"The parameter `arg` has been renamed to `func`, and it "
"will stop being supported in a future version of pandas.",
FutureWarning,
stacklevel=find_stack_level(),
)
else:
raise ValueError("The `func` parameter is required")

if engine is not None:
if not callable(func):
raise ValueError(
Expand Down
17 changes: 0 additions & 17 deletions pandas/tests/series/methods/test_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,30 +614,13 @@ def test_map_kwargs():
tm.assert_series_equal(result, expected)


def test_map_arg_as_kwarg():
with tm.assert_produces_warning(
FutureWarning, match="`arg` has been renamed to `func`"
):
Series([1, 2]).map(arg={})


def test_map_func_and_arg():
# `arg`is considered a normal kwarg that should be passed to the function
result = Series([1, 2]).map(lambda _, arg: arg, arg=3)
expected = Series([3, 3])
tm.assert_series_equal(result, expected)


def test_map_no_func_or_arg():
with pytest.raises(ValueError, match="The `func` parameter is required"):
Series([1, 2]).map()


def test_map_func_is_none():
with pytest.raises(ValueError, match="The `func` parameter is required"):
Series([1, 2]).map(func=None)


@pytest.mark.parametrize("func", [{}, {1: 2}, Series([3, 4])])
def test_map_engine_no_function(func):
s = Series([1, 2])
Expand Down
Loading