Skip to content

Commit 5d0f14a

Browse files
committed
update
1 parent 57e045a commit 5d0f14a

File tree

5 files changed

+21
-4
lines changed

5 files changed

+21
-4
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
@@ -57,6 +57,7 @@
5757
pandas_dtype,
5858
)
5959
from pandas.core.dtypes.dtypes import (
60+
ArrowDtype,
6061
DatetimeTZDtype,
6162
ExtensionDtype,
6263
PeriodDtype,

pandas/core/construction.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@
5151
is_object_dtype,
5252
pandas_dtype,
5353
)
54-
from pandas.core.dtypes.dtypes import PandasDtype, ArrowDtype
54+
from pandas.core.dtypes.dtypes import (
55+
ArrowDtype,
56+
PandasDtype,
57+
)
5558
from pandas.core.dtypes.generic import (
5659
ABCDataFrame,
5760
ABCExtensionArray,

pandas/core/dtypes/cast.py

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

832832
pa_dtype = pa.time64("us")
833-
from pandas.core.arrays.arrow import ArrowDtype
834833

835834
dtype = ArrowDtype(pa_dtype)
836835

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)