Skip to content

Add comment and test for geopandas compat fix (GH27259) #27287

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

Merged
merged 1 commit into from
Jul 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ def __getitem__(self, key):
# generally slice or list.
# TODO(ix): most/all of the TypeError cases here are for ix,
# so this check can be removed once ix is removed.
# The InvalidIndexError is only catched for compatibility
# with geopandas, see
# https://github.com/pandas-dev/pandas/issues/27258
pass
else:
if is_scalar(values):
Expand Down
22 changes: 21 additions & 1 deletion pandas/tests/test_downstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from pandas.compat import PY36

from pandas import DataFrame
from pandas import DataFrame, Series
from pandas.util import testing as tm


Expand Down Expand Up @@ -123,6 +123,26 @@ def test_geopandas():
assert geopandas.read_file(fp) is not None


def test_geopandas_coordinate_indexer():
# this test is included to have coverage of one case in the indexing.py
# code that is only kept for compatibility with geopandas, see
# https://github.com/pandas-dev/pandas/issues/27258
# We should be able to remove this after some time when its usage is
# removed in geopandas
from pandas.core.indexing import _NDFrameIndexer

class _CoordinateIndexer(_NDFrameIndexer):
def _getitem_tuple(self, tup):
obj = self.obj
xs, ys = tup
return obj[xs][ys]

Series._create_indexer("cx", _CoordinateIndexer)
s = Series(range(5))
res = s.cx[:, :]
tm.assert_series_equal(s, res)


# Cython import warning
@pytest.mark.filterwarnings("ignore:can't resolve:ImportWarning")
def test_pyarrow(df):
Expand Down