Skip to content

Commit ac79adc

Browse files
authored
ENH: Implement .dt.year for ArrowExtensionArray (#52330)
1 parent 09593b2 commit ac79adc

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

pandas/core/arrays/arrow/array.py

+4
Original file line numberDiff line numberDiff line change
@@ -1961,6 +1961,10 @@ def _str_wrap(self, width: int, **kwargs):
19611961
"str.wrap not supported with pd.ArrowDtype(pa.string())."
19621962
)
19631963

1964+
@property
1965+
def _dt_year(self):
1966+
return type(self)(pc.year(self._pa_array))
1967+
19641968
@property
19651969
def _dt_day(self):
19661970
return type(self)(pc.day(self._pa_array))

pandas/tests/extension/test_arrow.py

+1
Original file line numberDiff line numberDiff line change
@@ -2110,6 +2110,7 @@ def test_unsupported_dt(data):
21102110
@pytest.mark.parametrize(
21112111
"prop, expected",
21122112
[
2113+
["year", 2023],
21132114
["day", 2],
21142115
["day_of_week", 0],
21152116
["dayofweek", 0],

0 commit comments

Comments
 (0)