-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Possible regression in comparison operation for interval dtypes #28981
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
Comments
I think ive seen this before and found that changing |
Yep, that seems to fix it. Incidentally I also noticed this, which feels like it shouldn't be an error: [ins] In [14]: pd.Interval(1, 2) < pd.Interval(3, 4)
Out[14]: True
[ins] In [15]: s = pd.Series([pd.Interval(1, 2)], dtype="interval")
[ins] In [16]: s < pd.Interval(3, 4)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-16-91c971a412c6> in <module>
----> 1 s < pd.Interval(3, 4)
~/pandas/pandas/core/ops/__init__.py in wrapper(self, other)
527 rvalues = extract_array(other, extract_numpy=True)
528
--> 529 res_values = comparison_op(lvalues, rvalues, op)
530
531 return _construct_result(self, res_values, index=self.index, name=res_name)
~/pandas/pandas/core/ops/array_ops.py in comparison_op(left, right, op)
253
254 if should_extension_dispatch(lvalues, rvalues):
--> 255 res_values = dispatch_to_extension_op(op, lvalues, rvalues)
256
257 elif is_scalar(rvalues) and isna(rvalues):
~/pandas/pandas/core/ops/dispatch.py in dispatch_to_extension_op(op, left, right, keep_null_freq)
134
135 try:
--> 136 res_values = op(left, right)
137 except NullFrequencyError:
138 # DatetimeIndex and TimedeltaIndex with freq == None raise ValueError
TypeError: '<' not supported between instances of 'IntervalArray' and 'pandas._libs.interval.Interval' It works if you don't explicitly set [ins] In [17]: s = pd.Series([pd.Interval(1, 2)])
[ins] In [18]: s < pd.Interval(3, 4)
Out[18]:
0 True
dtype: bool |
It looks like IntervalArray comparison ops haven't been defined at all. That would be really nice to see fixed. PR welcome. |
This looks fixed in master. Could use a test
|
It seems that this comparison is now failing on master when it was working in 0.25.1. Need to look a bit more, but I don't think it's specific to this operation.
0.25.1
master
@jbrockmendel Is the fix for this as simple as (say) setting the
kind
to"O"
here https://github.com/pandas-dev/pandas/blob/master/pandas/core/dtypes/dtypes.py#L975? It looks like we're assuming thedtype
has akind
attribute when it doesn't.The text was updated successfully, but these errors were encountered: