From 2c2b47a67633e246f5ae2f4d42adc8d66694374f Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Tue, 30 Jul 2019 00:56:31 +0200 Subject: [PATCH 1/3] improve warnings for Series.{real,imag} --- doc/source/whatsnew/v0.25.1.rst | 2 +- pandas/core/series.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/source/whatsnew/v0.25.1.rst b/doc/source/whatsnew/v0.25.1.rst index fa9ca98f9c8d8..fb67decb46b64 100644 --- a/doc/source/whatsnew/v0.25.1.rst +++ b/doc/source/whatsnew/v0.25.1.rst @@ -64,7 +64,7 @@ Numeric Conversion ^^^^^^^^^^ -- +- Improved the warnings for the deprecated methods :meth:`Series.real` and :meth:`Series.imag` (:issue:`27610`) - - diff --git a/pandas/core/series.py b/pandas/core/series.py index b445ff5f944de..e1263569e9f91 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -955,7 +955,9 @@ def real(self): .. deprecated:: 0.25.0 """ warnings.warn( - "`real` has be deprecated and will be removed in a future version", + "`real` has be deprecated and will be removed in a future " + "version. To eliminate this warning for a Series ser, use " + "`np.real(ser.to_array())` or `ser.to_array().real`.", FutureWarning, stacklevel=2, ) @@ -973,7 +975,9 @@ def imag(self): .. deprecated:: 0.25.0 """ warnings.warn( - "`imag` has be deprecated and will be removed in a future version", + "`imag` has be deprecated and will be removed in a future " + "version. To eliminate this warning for a Series ser, use " + "`np.imag(ser.to_array())` or `ser.to_array().imag`.", FutureWarning, stacklevel=2, ) From 08d6f5e7a58dbcdd7c639239f7e2ea695d87c0b1 Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Tue, 30 Jul 2019 09:48:29 +0200 Subject: [PATCH 2/3] add more backticks (review gfyoung) --- pandas/core/series.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index e1263569e9f91..4d24d14041cab 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -956,7 +956,7 @@ def real(self): """ warnings.warn( "`real` has be deprecated and will be removed in a future " - "version. To eliminate this warning for a Series ser, use " + "version. To eliminate this warning for a Series `ser`, use " "`np.real(ser.to_array())` or `ser.to_array().real`.", FutureWarning, stacklevel=2, @@ -976,7 +976,7 @@ def imag(self): """ warnings.warn( "`imag` has be deprecated and will be removed in a future " - "version. To eliminate this warning for a Series ser, use " + "version. To eliminate this warning for a Series `ser`, use " "`np.imag(ser.to_array())` or `ser.to_array().imag`.", FutureWarning, stacklevel=2, From c187a961a55ce51f85945b2a0def9b12b63f69bf Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Tue, 30 Jul 2019 10:17:08 +0200 Subject: [PATCH 3/3] review jorisvandenbossche --- pandas/core/series.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 4d24d14041cab..106bb3c7d6cb4 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -955,9 +955,9 @@ def real(self): .. deprecated:: 0.25.0 """ warnings.warn( - "`real` has be deprecated and will be removed in a future " - "version. To eliminate this warning for a Series `ser`, use " - "`np.real(ser.to_array())` or `ser.to_array().real`.", + "`real` is deprecated and will be removed in a future version. " + "To eliminate this warning for a Series `ser`, use " + "`np.real(ser.to_numpy())` or `ser.to_numpy().real`.", FutureWarning, stacklevel=2, ) @@ -975,9 +975,9 @@ def imag(self): .. deprecated:: 0.25.0 """ warnings.warn( - "`imag` has be deprecated and will be removed in a future " - "version. To eliminate this warning for a Series `ser`, use " - "`np.imag(ser.to_array())` or `ser.to_array().imag`.", + "`imag` is deprecated and will be removed in a future version. " + "To eliminate this warning for a Series `ser`, use " + "`np.imag(ser.to_numpy())` or `ser.to_numpy().imag`.", FutureWarning, stacklevel=2, )