File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,9 @@ def __getitem__(self, key):
123123 # generally slice or list.
124124 # TODO(ix): most/all of the TypeError cases here are for ix,
125125 # so this check can be removed once ix is removed.
126+ # The InvalidIndexError is only catched for compatibility
127+ # with geopandas, see
128+ # https://github.com/pandas-dev/pandas/issues/27258
126129 pass
127130 else :
128131 if is_scalar (values ):
Original file line number Diff line number Diff line change 1010
1111from pandas .compat import PY36
1212
13- from pandas import DataFrame
13+ from pandas import DataFrame , Series
1414from pandas .util import testing as tm
1515
1616
@@ -123,6 +123,26 @@ def test_geopandas():
123123 assert geopandas .read_file (fp ) is not None
124124
125125
126+ def test_geopandas_coordinate_indexer ():
127+ # this test is included to have coverage of one case in the indexing.py
128+ # code that is only kept for compatibility with geopandas, see
129+ # https://github.com/pandas-dev/pandas/issues/27258
130+ # We should be able to remove this after some time when its usage is
131+ # removed in geopandas
132+ from pandas .core .indexing import _NDFrameIndexer
133+
134+ class _CoordinateIndexer (_NDFrameIndexer ):
135+ def _getitem_tuple (self , tup ):
136+ obj = self .obj
137+ xs , ys = tup
138+ return obj [xs ][ys ]
139+
140+ Series ._create_indexer ("cx" , _CoordinateIndexer )
141+ s = Series (range (5 ))
142+ res = s .cx [:, :]
143+ tm .assert_series_equal (s , res )
144+
145+
126146# Cython import warning
127147@pytest .mark .filterwarnings ("ignore:can't resolve:ImportWarning" )
128148def test_pyarrow (df ):
You can’t perform that action at this time.
0 commit comments