You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm pretty sure this is related to other questionable behavior:
index = pd.IntervalIndex([np.nan, np.nan])
other = pd.IntervalIndex([np.nan])
In [4]: index.is_monotonic # should be False
Out[4]: True
In [5]: index._index_as_unique # should be False
Out[5]: True
In [6]: index.get_indexer_for(other) # shouldn't raise
InvalidIndexError: Reindexing only valid with uniquely valued Index objects
The text was updated successfully, but these errors were encountered:
@jschendel I've got a branch trying to fix this and could use your input as ive broken a bunch of test_is_overlapping cases.
The main thing ive done is in IntervalTree.__init__ defined self._na_count = len(mask) - mask.sum(), then 1) edited is_monotonic to return False if self._na_count > 0 and 2) edited is_overlapping to return True if self._na_count > 1
Finally I've edited IntervalIndex._get_indexer_pointwise to handle np.nan
indexer, missing = [], []
for i, key in enumerate(target):
+ if is_interval_dtype(target.dtype) and isna(key):
+ # self.get_loc(np.nan) will treat it as a float instead of as
+ # our own dtype.
+ # TODO: handle this in get_loc?
+ locs = self.isna().nonzero()[0]
+ if len(locs) == 0:
+ missing.append(i)
else:
[what we have now, indented one more time]
This suffices to fix the three things in the OP, but breaks is_overlapping tests, so I'd like to get your thoughts on if this is the right way to solve this. (also how to keep get_indexer consistent with get_loc)
I'm pretty sure this is related to other questionable behavior:
The text was updated successfully, but these errors were encountered: