Skip to content

Commit 769b823

Browse files
committed
update
1 parent 2cb4116 commit 769b823

File tree

6 files changed

+22
-8
lines changed

6 files changed

+22
-8
lines changed

pandas/_libs/lib.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2649,7 +2649,7 @@ def maybe_convert_objects(ndarray[object] objects,
26492649
if opt is True:
26502650
import pyarrow as pa
26512651

2652-
from pandas.core.arrays.arrow import ArrowDtype
2652+
from pandas.core.dtypes.dtypes import ArrowDtype
26532653

26542654
obj = pa.array(objects)
26552655
dtype = ArrowDtype(obj.type)

pandas/core/arrays/arrow/array.py

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

634-
result = pc_func(self._pa_array, other)
634+
try:
635+
result = pc_func(self._pa_array, other)
636+
except pa.lib.ArrowNotImplementedError:
637+
if op in [operator.add, roperator.radd, operator.sub, roperator.rsub]:
638+
# By returning NotImplemented we get standard message with a
639+
# TypeError
640+
return NotImplemented
641+
raise
642+
635643
return type(self)(result)
636644

637645
def _logical_method(self, other, op):

pandas/core/arrays/datetimes.py

Lines changed: 1 addition & 2 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,
@@ -1363,8 +1364,6 @@ def time(self) -> npt.NDArray[np.object_] | ArrowExtensionArray:
13631364
# TODO: optimize this to avoid going through ints_to_pydatetime
13641365
import pyarrow as pa
13651366

1366-
from pandas.core.arrays.arrow import ArrowDtype
1367-
13681367
pa_type = pa.time64(self.unit)
13691368
result[self.isna()] = None
13701369
obj = pa.array(result, type=pa_type)

pandas/core/construction.py

Lines changed: 4 additions & 2 deletions
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
54+
from pandas.core.dtypes.dtypes import (
55+
ArrowDtype,
56+
PandasDtype,
57+
)
5558
from pandas.core.dtypes.generic import (
5659
ABCDataFrame,
5760
ABCExtensionArray,
@@ -297,7 +300,6 @@ def array(
297300
PeriodArray,
298301
TimedeltaArray,
299302
)
300-
from pandas.core.arrays.arrow import ArrowDtype
301303
from pandas.core.arrays.string_ import StringDtype
302304

303305
if lib.is_scalar(data):

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)