Skip to content

BUG: Mismatched Comparisons Inconsistencies #22042

Closed
@jbrockmendel

Description

@jbrockmendel
idx = pd.Index([2, 3])
ser = idx.to_series()
df = ser.to_frame()
foo = pd.Index(['foo', 'foo'])

>>> idx == 'foo'
False

>>> idx < 'foo'
PY2 --> False
PY3 --> TypeError

>>> ser == 'foo'
TypeError
>>> ser < 'foo'
TypeError

>>> ser == foo
2    False
3    False
dtype: bool

>>> ser < foo
PY2 --> All-True-Series
PY3 --> TypeError

>>> ser > foo
Py2 --> All-False-Series
PY3 --> TypeError

>>> df == 'foo'
       0
2  False
3  False

>>> df < 'foo'
      0
2  True
3  True

>>> df > 'foo'
PY2 --> All-False-DataFrame
PY3 --> All-True-DataFrame

>>> df == foo    # Same for inequalities
[...]
TypeError: reindex() got an unexpected keyword argument 'axis'

>>> df == pd.Series(foo)
       0      1
2  False  False
3  False  False

>>> df < pd.Series(foo)
PY2 --> All-True-DataFrame[2x2]
PY3 --> TypeError

>>> df > pd.Series(foo)
PY2 --> All-False-DataFrame[2x2]
PY3 --> TypeError

>>> df == pd.Series(foo, index=idx)
       0      2      3
2  False  False  False
3  False  False  False

>>> df < pd.Series(foo, index=idx)
PY3 --> TypeError
PY2 -->
       0     2     3
2  False  True  True
3  False  True  True

>>> df > pd.Series(foo, index=idx)
PY3 --> TypeError
PY2 -->
       0      2      3
2  False  False  False
3  False  False  False

Metadata

Metadata

Assignees

No one assigned

    Labels

    AlgosNon-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions