Impossible to use any variant of ".real/.imag" without warning · Issue #27610 · pandas-dev/pandas (original) (raw)

After #27106, Series.{real,imag} raise a deprecation warning, which I guess is fair enough from the POV of getting rid of things that came originally from subclassing ndarray.

>>> pd.Series([1, 2, 3]).real
__main__:1: FutureWarning: `real` has be deprecated and will be removed in a future verison
array([1, 2, 3], dtype=int64)

However, due to the way numpy and pandas still interact (with a lot of the __array__ stuff behind the scenes), it is now also impossible to use np.{real,imag} without warning:

>>> np.real(pd.Series([1, 2, 3]))
C:\ProgramData\Miniconda3\envs\pandas-dev\lib\site-packages\numpy\lib\type_check.py:161: FutureWarning: `real` has be deprecated and will be removed in a future verison
  return val.real
array([1, 2, 3], dtype=int64)

I'm fine with whichever way is recommended, but there should be at least one way that does not raise warnings...?

@mroeschke @jreback

PS. One might also use this chance to fix a typo: "[...] has be_en_ deprecated [...]"