Skip to content

eq and ne not consistent with other comparison operators #4968

Closed
@cpcloud

Description

@cpcloud

works

In [1]: df = DataFrame(randint(10, size=(10, 1)), columns=['a'])

In [2]: df['dates'] = date_range('20010101', periods=len(df))

In [3]: df.a == df.dates
Out[3]:
0    False
1    False
2    False
3    False
4    False
5    False
6    False
7    False
8    False
9    False
dtype: bool

doesn't work:

In [4]: df.a <= df.dates
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-4-74e89260dea7> in <module>()
----> 1 df.a <= df.dates

/home/phillip/Documents/code/py/pandas/pandas/core/series.pyc in wrapper(self, other)
    336             if len(self) != len(other):
    337                 raise ValueError('Series lengths must match to compare')
--> 338             return self._constructor(na_op(self.values, other.values),
    339                                      index=self.index, name=name)
    340         elif isinstance(other, DataFrame):  # pragma: no cover

/home/phillip/Documents/code/py/pandas/pandas/core/series.pyc in na_op(x, y)
    325                 result = lib.scalar_compare(x, y, op)
    326         else:
--> 327             result = op(x, y)
    328
    329         return result

TypeError: invalid type promotion

Metadata

Metadata

Assignees

No one assigned

    Labels

    Dtype ConversionsUnexpected or buggy dtype conversions

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions