Skip to content

Commit a13c766

Browse files
committed
BUG: Fix .dt.microsecond accessor for pyarrow-backed Series
1 parent dcb5494 commit a13c766

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

pandas/core/arrays/arrow/array.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2794,7 +2794,10 @@ def _dt_days_in_month(self) -> Self:
27942794

27952795
@property
27962796
def _dt_microsecond(self) -> Self:
2797-
return type(self)(pc.microsecond(self._pa_array))
2797+
# GH 59154
2798+
us = pc.microsecond(self._pa_array)
2799+
ms_to_us = pc.multiply(pc.millisecond(self._pa_array), 1000)
2800+
return type(self)(pc.add(us, ms_to_us))
27982801

27992802
@property
28002803
def _dt_minute(self) -> Self:

pandas/tests/extension/test_arrow.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2437,13 +2437,13 @@ def test_unsupported_dt(data):
24372437
["hour", 3],
24382438
["minute", 4],
24392439
["is_leap_year", False],
2440-
["microsecond", 5],
2440+
["microsecond", 2000],
24412441
["month", 1],
24422442
["nanosecond", 6],
24432443
["quarter", 1],
24442444
["second", 7],
24452445
["date", date(2023, 1, 2)],
2446-
["time", time(3, 4, 7, 5)],
2446+
["time", time(3, 4, 7, 2000)],
24472447
],
24482448
)
24492449
def test_dt_properties(prop, expected):
@@ -2456,7 +2456,7 @@ def test_dt_properties(prop, expected):
24562456
hour=3,
24572457
minute=4,
24582458
second=7,
2459-
microsecond=5,
2459+
microsecond=2000,
24602460
nanosecond=6,
24612461
),
24622462
None,

0 commit comments

Comments
 (0)