-
-
Notifications
You must be signed in to change notification settings - Fork 978
Closed
Description
See pandas-dev/pandas#27258, recent change in pandas broke some CoordinateIndexer tests.
The current implementation of CoordinateIndexer:
Lines 734 to 761 in 7c66c93
class _CoordinateIndexer(_NDFrameIndexer): | |
""" | |
Coordinate based indexer to select by intersection with bounding box. | |
Format of input should be ``.cx[xmin:xmax, ymin:ymax]``. Any of ``xmin``, | |
``xmax``, ``ymin``, and ``ymax`` can be provided, but input must | |
include a comma separating x and y slices. That is, ``.cx[:, :]`` will | |
return the full series/frame, but ``.cx[:]`` is not implemented. | |
""" | |
def _getitem_tuple(self, tup): | |
obj = self.obj | |
xs, ys = tup | |
# handle numeric values as x and/or y coordinate index | |
if type(xs) is not slice: | |
xs = slice(xs, xs) | |
if type(ys) is not slice: | |
ys = slice(ys, ys) | |
# don't know how to handle step; should this raise? | |
if xs.step is not None or ys.step is not None: | |
warn("Ignoring step - full interval is used.") | |
xmin, ymin, xmax, ymax = obj.total_bounds | |
bbox = box(xs.start if xs.start is not None else xmin, | |
ys.start if ys.start is not None else ymin, | |
xs.stop if xs.stop is not None else xmax, | |
ys.stop if ys.stop is not None else ymax) | |
idx = obj.intersects(bbox) | |
return obj[idx] |
is relying on some pandas internals. We should see if we can make this cleaner.
I actually think this only needs the __getitem__
of its parent _NDFrameIndexer
, so that is something we could implement rather easily ourselves.
In addition, we use DataFrame/Series._create_indexer
, but this is also only 3 lines of code.
Metadata
Metadata
Assignees
Labels
No labels