Skip to content

Commit 4658f34

Browse files
committed
update
1 parent af84ddf commit 4658f34

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

pandas/core/arrays/arrow/array.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,15 @@ def _evaluate_op_method(self, other, op, arrow_funcs):
649649
if pc_func is NotImplemented:
650650
raise NotImplementedError(f"{op.__name__} not implemented.")
651651

652-
result = pc_func(self._pa_array, other)
652+
try:
653+
result = pc_func(self._pa_array, other)
654+
except pa.lib.ArrowNotImplementedError:
655+
if op in [operator.add, roperator.radd, operator.sub, roperator.rsub]:
656+
# By returning NotImplemented we get standard message with a
657+
# TypeError
658+
return NotImplemented
659+
raise
660+
653661
return type(self)(result)
654662

655663
def _logical_method(self, other, op):

pandas/core/arrays/datetimes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
pandas_dtype,
5656
)
5757
from pandas.core.dtypes.dtypes import (
58+
ArrowDtype,
5859
DatetimeTZDtype,
5960
ExtensionDtype,
6061
PeriodDtype,

pandas/core/dtypes/cast.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,6 @@ def infer_dtype_from_scalar(val) -> tuple[DtypeObj, Any]:
844844
import pyarrow as pa
845845

846846
pa_dtype = pa.time64("us")
847-
from pandas.core.arrays.arrow import ArrowDtype
848847

849848
dtype = ArrowDtype(pa_dtype)
850849

pandas/tests/arithmetic/test_datetime64.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1171,11 +1171,17 @@ def test_dt64arr_add_sub_parr(
11711171
"future", [pytest.param(True, marks=td.skip_if_no("pyarrow")), False, None]
11721172
)
11731173
def test_dt64arr_addsub_time_objects_raises(
1174-
self, box_with_array, tz_naive_fixture, future
1174+
self, box_with_array, tz_naive_fixture, future, request
11751175
):
11761176
# https://github.com/pandas-dev/pandas/issues/10329
11771177

11781178
tz = tz_naive_fixture
1179+
if str(tz) == "tzlocal()" and future is True:
1180+
# TODO(GH#53278)
1181+
mark = pytest.mark.xfail(
1182+
reason="Incorrectly raises AttributeError instead of TypeError"
1183+
)
1184+
request.node.add_marker(mark)
11791185

11801186
obj1 = date_range("2012-01-01", periods=3, tz=tz)
11811187
obj2 = [time(i, i, i) for i in range(3)]

0 commit comments

Comments
 (0)