Skip to content

Commit 94fd426

Browse files
committed
update
1 parent 037a0c6 commit 94fd426

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
@@ -651,7 +651,15 @@ def _evaluate_op_method(self, other, op, arrow_funcs):
651651
if pc_func is NotImplemented:
652652
raise NotImplementedError(f"{op.__name__} not implemented.")
653653

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

657665
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
@@ -841,7 +841,6 @@ def infer_dtype_from_scalar(val) -> tuple[DtypeObj, Any]:
841841
import pyarrow as pa
842842

843843
pa_dtype = pa.time64("us")
844-
from pandas.core.arrays.arrow import ArrowDtype
845844

846845
dtype = ArrowDtype(pa_dtype)
847846

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)