Skip to content

Invalid Type Comparison between numerical column and empty string #16902

Closed
@alexanderwhatley

Description

@alexanderwhatley

Seems like a bug, such a comparison should definitely be allowed. Pandas Version 0.20.2, Ubuntu.

In [2]: import pandas as pd

In [3]: df = pd.DataFrame({"a" : [1,2], "b" : [2,3]})

In [4]: import numpy as np

In [5]: np.all(df["a"] == "")
/home/alexander/anaconda3/lib/python3.5/site-packages/pandas/core/ops.py:798: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  result = getattr(x, name)(y)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-346e9f7bf435> in <module>()
----> 1 np.all(df["a"] == "")

/home/alexander/anaconda3/lib/python3.5/site-packages/pandas/core/ops.py in wrapper(self, other, axis)
    859 
    860             with np.errstate(all='ignore'):
--> 861                 res = na_op(values, other)
    862             if is_scalar(res):
    863                 raise TypeError('Could not compare %s type with Series' %

/home/alexander/anaconda3/lib/python3.5/site-packages/pandas/core/ops.py in na_op(x, y)
    798                     result = getattr(x, name)(y)
    799                 if result is NotImplemented:
--> 800                     raise TypeError("invalid type comparison")
    801             except AttributeError:
    802                 result = op(x, y)

TypeError: invalid type comparison

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions