From 2bb7eda6e6e05d14284bdf7653e3773ff01bdd13 Mon Sep 17 00:00:00 2001 From: "fillipe.gsm" Date: Wed, 13 Jun 2018 22:49:16 -0300 Subject: [PATCH 1/2] BUG: Add np.complex64 and np.complex_ to acceptable dtypes to handle division in eval() without discarding imaginary part with complex data closes #21374 --- pandas/core/computation/ops.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandas/core/computation/ops.py b/pandas/core/computation/ops.py index ca0c4db4947c4..30ee3671b15e2 100644 --- a/pandas/core/computation/ops.py +++ b/pandas/core/computation/ops.py @@ -465,8 +465,9 @@ def __init__(self, lhs, rhs, truediv, *args, **kwargs): rhs.return_type)) if truediv or PY3: - # do not upcast float32s to float64 un-necessarily - acceptable_dtypes = [np.float32, np.float_] + # do not upcast float32s to float64 un-necessarily + acceptable_dtypes = [np.float32, np.float_, + np.complex64, np.complex_] _cast_inplace(com.flatten(self), acceptable_dtypes, np.float_) From 72252e1b87a0a06fd1bec9c7c7548bae33d7b738 Mon Sep 17 00:00:00 2001 From: "fillipe.gsm" Date: Wed, 13 Jun 2018 23:15:05 -0300 Subject: [PATCH 2/2] Remove trailing whitespace --- pandas/core/computation/ops.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/computation/ops.py b/pandas/core/computation/ops.py index 30ee3671b15e2..e9403a48dd157 100644 --- a/pandas/core/computation/ops.py +++ b/pandas/core/computation/ops.py @@ -465,7 +465,7 @@ def __init__(self, lhs, rhs, truediv, *args, **kwargs): rhs.return_type)) if truediv or PY3: - # do not upcast float32s to float64 un-necessarily + # do not upcast float32s to float64 un-necessarily acceptable_dtypes = [np.float32, np.float_, np.complex64, np.complex_] _cast_inplace(com.flatten(self), acceptable_dtypes, np.float_)