diff --git a/doc/source/whatsnew/v3.0.0.rst b/doc/source/whatsnew/v3.0.0.rst index 7eb7605a47aa1..7b337735c8637 100644 --- a/doc/source/whatsnew/v3.0.0.rst +++ b/doc/source/whatsnew/v3.0.0.rst @@ -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`) diff --git a/pandas/core/series.py b/pandas/core/series.py index 00cff09801f1a..785c7aabcacd7 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -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, @@ -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, @@ -4368,7 +4365,7 @@ def map( **kwargs Additional keyword arguments to pass as keywords arguments to - `arg`. + `func`. .. versionadded:: 3.0.0 @@ -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( diff --git a/pandas/tests/series/methods/test_map.py b/pandas/tests/series/methods/test_map.py index 0ec973dea23d5..93d02b50bdeed 100644 --- a/pandas/tests/series/methods/test_map.py +++ b/pandas/tests/series/methods/test_map.py @@ -614,13 +614,6 @@ 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) @@ -628,16 +621,6 @@ def test_map_func_and_arg(): 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])