Skip to content

Commit 9bf45db

Browse files
meeseeksmachinemroeschkephofl
authored
Backport PR #52330 on branch 2.0.x (ENH: Implement .dt.year for ArrowExtensionArray) (#52359)
* Backport PR #52330: ENH: Implement .dt.year for ArrowExtensionArray * Update array.py --------- Co-authored-by: Matthew Roeschke <[email protected]> Co-authored-by: Patrick Hoefler <[email protected]>
1 parent 7c56e05 commit 9bf45db

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Diff for: pandas/core/arrays/arrow/array.py

+4
Original file line numberDiff line numberDiff line change
@@ -1945,6 +1945,10 @@ def _str_wrap(self, width, **kwargs):
19451945
"str.wrap not supported with pd.ArrowDtype(pa.string())."
19461946
)
19471947

1948+
@property
1949+
def _dt_year(self):
1950+
return type(self)(pc.year(self._data))
1951+
19481952
@property
19491953
def _dt_day(self):
19501954
return type(self)(pc.day(self._data))

Diff for: pandas/tests/extension/test_arrow.py

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

0 commit comments

Comments
 (0)