Skip to content

BUG: Mismatched Comparisons Inconsistencies #22042

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jbrockmendel opened this issue Jul 24, 2018 · 4 comments
Closed

BUG: Mismatched Comparisons Inconsistencies #22042

jbrockmendel opened this issue Jul 24, 2018 · 4 comments
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff

Comments

@jbrockmendel
Copy link
Member

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
@gfyoung gfyoung added 2/3 Compat Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff labels Jul 27, 2018
@gfyoung
Copy link
Member

gfyoung commented Jul 27, 2018

Too bad Python 2.x is a thing still...

@gfyoung
Copy link
Member

gfyoung commented Mar 26, 2019

@jbrockmendel @jreback : Since we're moving to PY3-only, I think we can close this?

@jbrockmendel
Copy link
Member Author

Depends on whether we want to call the py2 versions "bugs" and address in a 0.24.x; I'd be pretty happy letting this go.

@jreback
Copy link
Contributor

jreback commented Mar 26, 2019

if someone wants to submit a PR sure but otherwise out of scope

@jreback jreback closed this as completed Mar 26, 2019
@gfyoung gfyoung added this to the No action milestone Mar 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff
Projects
None yet
Development

No branches or pull requests

3 participants