Skip to content
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

Invalid Type Comparison between numerical column and empty string #16902

Closed
alexanderwhatley opened this issue Jul 13, 2017 · 1 comment
Closed
Labels
Duplicate Report Duplicate issue or pull request

Comments

@alexanderwhatley
Copy link

alexanderwhatley commented Jul 13, 2017

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
@chris-b1
Copy link
Contributor

This is duplicate of #7830 - to be honest I don't mind us raising an exception here, although I know it conflicts with python semantics as discussed there. also xref #13129

@chris-b1 chris-b1 added the Duplicate Report Duplicate issue or pull request label Jul 13, 2017
@chris-b1 chris-b1 added this to the No action milestone Jul 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request
Projects
None yet
Development

No branches or pull requests

2 participants