Skip to content

Commit 143bc34

Browse files
h-vetinarijorisvandenbossche
authored andcommitted
DOC: improve warnings for Series.{real,imag} (#27651)
1 parent ffcbfc8 commit 143bc34

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

doc/source/whatsnew/v0.25.1.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Numeric
6464
Conversion
6565
^^^^^^^^^^
6666

67-
-
67+
- Improved the warnings for the deprecated methods :meth:`Series.real` and :meth:`Series.imag` (:issue:`27610`)
6868
-
6969
-
7070

pandas/core/series.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,9 @@ def real(self):
955955
.. deprecated:: 0.25.0
956956
"""
957957
warnings.warn(
958-
"`real` has be deprecated and will be removed in a future version",
958+
"`real` is deprecated and will be removed in a future version. "
959+
"To eliminate this warning for a Series `ser`, use "
960+
"`np.real(ser.to_numpy())` or `ser.to_numpy().real`.",
959961
FutureWarning,
960962
stacklevel=2,
961963
)
@@ -973,7 +975,9 @@ def imag(self):
973975
.. deprecated:: 0.25.0
974976
"""
975977
warnings.warn(
976-
"`imag` has be deprecated and will be removed in a future version",
978+
"`imag` is deprecated and will be removed in a future version. "
979+
"To eliminate this warning for a Series `ser`, use "
980+
"`np.imag(ser.to_numpy())` or `ser.to_numpy().imag`.",
977981
FutureWarning,
978982
stacklevel=2,
979983
)

0 commit comments

Comments
 (0)