Skip to content

Commit 506b238

Browse files
jbrockmendelproost
authored andcommitted
DEPR: remove real, imag, put, and str.partition kwarg (pandas-dev#29986)
1 parent 0c643c9 commit 506b238

File tree

8 files changed

+10
-100
lines changed

8 files changed

+10
-100
lines changed

doc/redirects.csv

-1
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,6 @@ generated/pandas.Series.pow,../reference/api/pandas.Series.pow
11191119
generated/pandas.Series.prod,../reference/api/pandas.Series.prod
11201120
generated/pandas.Series.product,../reference/api/pandas.Series.product
11211121
generated/pandas.Series.ptp,../reference/api/pandas.Series.ptp
1122-
generated/pandas.Series.put,../reference/api/pandas.Series.put
11231122
generated/pandas.Series.quantile,../reference/api/pandas.Series.quantile
11241123
generated/pandas.Series.radd,../reference/api/pandas.Series.radd
11251124
generated/pandas.Series.rank,../reference/api/pandas.Series.rank

doc/source/reference/series.rst

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ Attributes
3939
Series.empty
4040
Series.dtypes
4141
Series.name
42-
Series.put
4342

4443
Conversion
4544
----------

doc/source/whatsnew/v1.0.0.rst

+3
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,9 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
565565
- Passing multiple axes to :meth:`DataFrame.dropna` is no longer supported (:issue:`20995`)
566566
- Removed previously deprecated :meth:`Series.nonzero`, use `to_numpy().nonzero()` instead (:issue:`24048`)
567567
- Passing floating dtype ``codes`` to :meth:`Categorical.from_codes` is no longer supported, pass ``codes.astype(np.int64)`` instead (:issue:`21775`)
568+
- :meth:`Series.str.partition` and :meth:`Series.str.rpartition` no longer accept "pat" keyword, use "sep" instead (:issue:`23767`)
569+
- Removed the previously deprecated :meth:`Series.put` (:issue:`27106`)
570+
- Removed the previously deprecated :attr:`Series.real`, :attr:`Series.imag` (:issue:`27106`)
568571
- Removed the previously deprecated :meth:`Series.to_dense`, :meth:`DataFrame.to_dense` (:issue:`26684`)
569572
- Removed the previously deprecated :meth:`Index.dtype_str`, use ``str(index.dtype)`` instead (:issue:`27106`)
570573
- :meth:`Categorical.ravel` returns a :class:`Categorical` instead of a ``ndarray`` (:issue:`27199`)

pandas/core/series.py

+1-58
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class Series(base.IndexOpsMixin, generic.NDFrame):
158158
_deprecations = (
159159
base.IndexOpsMixin._deprecations
160160
| generic.NDFrame._deprecations
161-
| frozenset(["compress", "valid", "real", "imag", "put", "ptp", "nonzero"])
161+
| frozenset(["compress", "ptp"])
162162
)
163163

164164
# Override cache_readonly bc Series is mutable
@@ -528,23 +528,6 @@ def compress(self, condition, *args, **kwargs):
528528
nv.validate_compress(args, kwargs)
529529
return self[condition]
530530

531-
def put(self, *args, **kwargs):
532-
"""
533-
Apply the `put` method to its `values` attribute if it has one.
534-
535-
.. deprecated:: 0.25.0
536-
537-
See Also
538-
--------
539-
numpy.ndarray.put
540-
"""
541-
warnings.warn(
542-
"`put` has been deprecated and will be removed in a future version.",
543-
FutureWarning,
544-
stacklevel=2,
545-
)
546-
self._values.put(*args, **kwargs)
547-
548531
def __len__(self) -> int:
549532
"""
550533
Return the length of the Series.
@@ -777,46 +760,6 @@ def __array__(self, dtype=None):
777760
# ----------------------------------------------------------------------
778761
# Unary Methods
779762

780-
@property
781-
def real(self):
782-
"""
783-
Return the real value of vector.
784-
785-
.. deprecated:: 0.25.0
786-
"""
787-
warnings.warn(
788-
"`real` is deprecated and will be removed in a future version. "
789-
"To eliminate this warning for a Series `ser`, use "
790-
"`np.real(ser.to_numpy())` or `ser.to_numpy().real`.",
791-
FutureWarning,
792-
stacklevel=2,
793-
)
794-
return self.values.real
795-
796-
@real.setter
797-
def real(self, v):
798-
self.values.real = v
799-
800-
@property
801-
def imag(self):
802-
"""
803-
Return imag value of vector.
804-
805-
.. deprecated:: 0.25.0
806-
"""
807-
warnings.warn(
808-
"`imag` is deprecated and will be removed in a future version. "
809-
"To eliminate this warning for a Series `ser`, use "
810-
"`np.imag(ser.to_numpy())` or `ser.to_numpy().imag`.",
811-
FutureWarning,
812-
stacklevel=2,
813-
)
814-
return self.values.imag
815-
816-
@imag.setter
817-
def imag(self, v):
818-
self.values.imag = v
819-
820763
# coercion
821764
__float__ = _coerce_method(float)
822765
__long__ = _coerce_method(int)

pandas/core/strings.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import pandas._libs.lib as lib
1111
import pandas._libs.ops as libops
12-
from pandas.util._decorators import Appender, deprecate_kwarg
12+
from pandas.util._decorators import Appender
1313

1414
from pandas.core.dtypes.common import (
1515
ensure_object,
@@ -2628,9 +2628,6 @@ def rsplit(self, pat=None, n=-1, expand=False):
26282628
----------
26292629
sep : str, default whitespace
26302630
String to split on.
2631-
pat : str, default whitespace
2632-
.. deprecated:: 0.24.0
2633-
Use ``sep`` instead.
26342631
expand : bool, default True
26352632
If True, return DataFrame/MultiIndex expanding dimensionality.
26362633
If False, return Series/Index.
@@ -2708,7 +2705,6 @@ def rsplit(self, pat=None, n=-1, expand=False):
27082705
"also": "rpartition : Split the string at the last occurrence of `sep`.",
27092706
}
27102707
)
2711-
@deprecate_kwarg(old_arg_name="pat", new_arg_name="sep")
27122708
@forbid_nonstring_types(["bytes"])
27132709
def partition(self, sep=" ", expand=True):
27142710
f = lambda x: x.partition(sep)
@@ -2724,7 +2720,6 @@ def partition(self, sep=" ", expand=True):
27242720
"also": "partition : Split the string at the first occurrence of `sep`.",
27252721
}
27262722
)
2727-
@deprecate_kwarg(old_arg_name="pat", new_arg_name="sep")
27282723
@forbid_nonstring_types(["bytes"])
27292724
def rpartition(self, sep=" ", expand=True):
27302725
f = lambda x: x.rpartition(sep)

pandas/tests/series/test_dtypes.py

-20
Original file line numberDiff line numberDiff line change
@@ -411,26 +411,6 @@ def test_astype_empty_constructor_equality(self, dtype):
411411
as_type_empty = Series([]).astype(dtype)
412412
tm.assert_series_equal(init_empty, as_type_empty)
413413

414-
@pytest.mark.filterwarnings("ignore::FutureWarning")
415-
def test_complex(self):
416-
# see gh-4819: complex access for ndarray compat
417-
a = np.arange(5, dtype=np.float64)
418-
b = Series(a + 4j * a)
419-
420-
tm.assert_numpy_array_equal(a, np.real(b))
421-
tm.assert_numpy_array_equal(4 * a, np.imag(b))
422-
423-
b.real = np.arange(5) + 5
424-
tm.assert_numpy_array_equal(a + 5, np.real(b))
425-
tm.assert_numpy_array_equal(4 * a, np.imag(b))
426-
427-
def test_real_imag_deprecated(self):
428-
# GH 18262
429-
s = pd.Series([1])
430-
with tm.assert_produces_warning(FutureWarning):
431-
s.imag
432-
s.real
433-
434414
def test_arg_for_errors_in_astype(self):
435415
# see gh-14878
436416
s = Series([1, 2, 3])

pandas/tests/series/test_internals.py

-7
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,3 @@ def test_hasnans_unchached_for_series():
242242
ser.iloc[-1] = np.nan
243243
assert ser.hasnans is True
244244
assert Series.hasnans.__doc__ == pd.Index.hasnans.__doc__
245-
246-
247-
def test_put_deprecated():
248-
# GH 18262
249-
s = pd.Series([1])
250-
with tm.assert_produces_warning(FutureWarning):
251-
s.put(0, 0)

pandas/tests/test_strings.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -2966,23 +2966,21 @@ def test_partition_with_name(self):
29662966
assert res.nlevels == 1
29672967
tm.assert_index_equal(res, exp)
29682968

2969-
def test_partition_deprecation(self):
2969+
def test_partition_sep_kwarg(self):
29702970
# GH 22676; depr kwarg "pat" in favor of "sep"
29712971
values = Series(["a_b_c", "c_d_e", np.nan, "f_g_h"])
29722972

29732973
# str.partition
29742974
# using sep -> no warning
29752975
expected = values.str.partition(sep="_")
2976-
with tm.assert_produces_warning(FutureWarning):
2977-
result = values.str.partition(pat="_")
2978-
tm.assert_frame_equal(result, expected)
2976+
result = values.str.partition("_")
2977+
tm.assert_frame_equal(result, expected)
29792978

29802979
# str.rpartition
29812980
# using sep -> no warning
29822981
expected = values.str.rpartition(sep="_")
2983-
with tm.assert_produces_warning(FutureWarning):
2984-
result = values.str.rpartition(pat="_")
2985-
tm.assert_frame_equal(result, expected)
2982+
result = values.str.rpartition("_")
2983+
tm.assert_frame_equal(result, expected)
29862984

29872985
def test_pipe_failures(self):
29882986
# #2119

0 commit comments

Comments
 (0)