Skip to content

Commit 08b1c3b

Browse files
authored
Pandas fix (#76)
* Fix ellipsis * Fix error messages * Fix fill unpack * pin pip to make tests pass * Better handling of get_fill_func
1 parent 9252a7a commit 08b1c3b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jobs:
5858
run: |
5959
eval "$(conda shell.bash hook)"
6060
conda activate test-environment
61+
conda install ${{ env.CHANS_DEV }} "pip<21.2.1"
6162
conda list
6263
doit develop_install ${{ env.CHANS_DEV }} -o tests
6364
- name: doit env_capture

spatialpandas/geometry/base.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,12 @@ def __len__(self):
355355
def __getitem__(self, item):
356356
err_msg = ("Only integers, slices and integer or boolean"
357357
"arrays are valid indices.")
358+
if isinstance(item, tuple) and len(item) == 2:
359+
if item[0] is Ellipsis:
360+
item = item[1]
361+
elif item[1] is Ellipsis:
362+
item = item[0]
363+
358364
if isinstance(item, Integral):
359365
item = int(item)
360366
if item < -len(self) or item >= len(self):
@@ -390,7 +396,7 @@ def __getitem__(self, item):
390396
# Check mask length is compatible
391397
if len(item) != len(self):
392398
raise IndexError(
393-
"boolean mask length ({}) doesn't match array length ({})"
399+
"Boolean index has wrong length: {} instead of {}"
394400
.format(len(item), len(self))
395401
)
396402

@@ -423,7 +429,7 @@ def take(self, indices, allow_fill=False, fill_value=None):
423429
# Validate self non-empty (Pandas expects this error when array is empty)
424430
if (len(self) == 0 and len(indices) > 0 and
425431
(not allow_fill or any(indices >= 0))):
426-
raise IndexError("cannot do a non-empty take on {typ}".format(
432+
raise IndexError("cannot do a non-empty take from an empty axes|out of bounds on {typ}".format(
427433
typ=self.__class__.__name__,
428434
))
429435

@@ -526,6 +532,8 @@ def fillna(self, value=None, method=None, limit=None):
526532
if method is not None:
527533
func = get_fill_func(method)
528534
new_values = func(self.astype(object), limit=limit, mask=mask)
535+
# From pandas 1.3, get_fill_func also return mask
536+
new_values = new_values[0] if isinstance(new_values, tuple) else new_values
529537
new_values = self._from_sequence(new_values, self._dtype)
530538
else:
531539
# fill with value

0 commit comments

Comments
 (0)