Skip to content

Commit

Permalink
Backport PR pandas-dev#52330: ENH: Implement .dt.year for ArrowExtens…
Browse files Browse the repository at this point in the history
…ionArray
  • Loading branch information
mroeschke authored and meeseeksmachine committed Apr 2, 2023
1 parent c922324 commit ee2c84f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pandas/core/arrays/arrow/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -1945,6 +1945,10 @@ def _str_wrap(self, width, **kwargs):
"str.wrap not supported with pd.ArrowDtype(pa.string())."
)

@property
def _dt_year(self):
return type(self)(pc.year(self._pa_array))

@property
def _dt_day(self):
return type(self)(pc.day(self._data))
Expand Down
1 change: 1 addition & 0 deletions pandas/tests/extension/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2109,6 +2109,7 @@ def test_unsupported_dt(data):
@pytest.mark.parametrize(
"prop, expected",
[
["year", 2023],
["day", 2],
["day_of_week", 0],
["dayofweek", 0],
Expand Down

0 comments on commit ee2c84f

Please sign in to comment.