Skip to content

Commit e56b1b3

Browse files
author
Rohan Jain
committed
bug fix
1 parent c992e77 commit e56b1b3

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

pandas/core/arrays/arrow/array.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,10 @@ def floordiv_compat(
136136
# which always inferred as int64, to prevent overflow
137137
# in case of large uint64 values.
138138
pc.and_(
139-
pc.less(divided, pa.scalar(0, type=divided.type)), has_remainder
139+
pc.less(
140+
pc.bit_wise_xor(left, right), pa.scalar(0, type=divided.type)
141+
),
142+
has_remainder,
140143
),
141144
# GH 55561: floordiv should round towards negative infinity.
142145
# pv.divide for integral types rounds towards 0.

pandas/tests/extension/test_arrow.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3253,6 +3253,14 @@ def test_arrow_floordiv_large_integral_result():
32533253
tm.assert_series_equal(result, a)
32543254

32553255

3256+
def test_arrow_floordiv_larger_divisor():
3257+
# GH 56676
3258+
a = pd.Series([-23], dtype="int64[pyarrow]")
3259+
result = a // 24
3260+
expected = pd.Series([-1], dtype="int64[pyarrow]")
3261+
tm.assert_series_equal(result, expected)
3262+
3263+
32563264
def test_arrow_floordiv_no_overflow():
32573265
# GH 56676
32583266
a = pd.Series([9223372036854775808], dtype="uint64[pyarrow]")

0 commit comments

Comments
 (0)