Skip to content

Commit 5b1b9fb

Browse files
committed
Workaround for Pandas issue 42430
1 parent d804c92 commit 5b1b9fb

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

text_extensions_for_pandas/array/tensor.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -523,15 +523,24 @@ def __getitem__(self, item) -> Union["TensorArray", "TensorElement"]:
523523
See docstring in `Extension Array` class in `pandas/core/arrays/base.py`
524524
for information about this method.
525525
"""
526-
# Return scalar if single value is selected, a TensorElement for single array element,
527-
# or TensorArray for slice
526+
# Return scalar if single value is selected, a TensorElement for single array
527+
# element, or TensorArray for slice
528528
if isinstance(item, int):
529529
value = self._tensor[item]
530530
if np.isscalar(value):
531531
return value
532532
else:
533533
return TensorElement(value)
534534
else:
535+
# BEGIN workaround for Pandas issue #42430
536+
if (pd.__version__ == "1.3.0" and isinstance(item, tuple) and len(item) > 1
537+
and item[0] == Ellipsis):
538+
if len(item) > 2:
539+
# Hopefully this case is not possible, but can't be sure
540+
raise ValueError(f"Workaround Pandas issue #42430 not implemented "
541+
f"for tuple length > 2")
542+
item = item[1]
543+
# END workaround for issue #42430
535544
if isinstance(item, TensorArray):
536545
item = np.asarray(item)
537546
item = check_array_indexer(self, item)

0 commit comments

Comments
 (0)