Skip to content

Commit ecda573

Browse files
committed
geshi
1 parent c5f0eb4 commit ecda573

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

pandas/core/arrays/arrow/accessors.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,11 @@ def __getitem__(self, key: int | slice) -> Series:
168168
if not arr.is_null()[i].as_py():
169169
current_length = lengths[i].as_py()
170170
if current_length == 0:
171-
raise IndexError(f"Index {key} is out of bounds: should be in [0, 0)")
171+
raise IndexError(
172+
f"Index {key} is out of bounds: should be in [0, 0)")
172173
if current_length < abs(key):
173-
raise IndexError(f"Index {key} is out of bounds: should be in [{-current_length}, {current_length})")
174+
raise IndexError(
175+
f"Index {key} is out of bounds: should be in [{-current_length}, {current_length})")
174176
chunks = arr.chunks if isinstance(arr, pa.ChunkedArray) else [arr]
175177
all_results = []
176178
for chunk in chunks:
@@ -188,7 +190,9 @@ def __getitem__(self, key: int | slice) -> Series:
188190
else:
189191
chunk_result = taken_values
190192
all_results.append(chunk_result)
191-
result_values = pa.concat_arrays(all_results) if all_results else pa.array([],type=arr.type.value_type)
193+
result_values = pa.concat_arrays(
194+
all_results) if all_results else pa.array([],
195+
type=arr.type.value_type)
192196
return Series(
193197
result_values,
194198
dtype=ArrowDtype(result_values.type),

pandas/tests/series/accessors/test_list_accessor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ def test_list_getitem_negative_index():
4141
tm.assert_series_equal(actual, expected)
4242

4343
ser_empty = Series([[]], dtype=ArrowDtype(pa.list_(pa.int64())))
44-
with pytest.raises(IndexError, match="Index -1 is out of bounds: should be in \\[0, 0\\)"):
44+
with pytest.raises(
45+
IndexError, match="Index -1 is out of bounds: should be in \\[0, 0\\)"):
4546
ser_empty.list[-1]
4647

4748
ser_mixed = Series([[1], [1, 2], [1, 2, 3]], dtype=ArrowDtype(pa.list_(pa.int64())))

0 commit comments

Comments
 (0)