Skip to content

Commit

Permalink
Return ndarray from DatetimeArray.week
Browse files Browse the repository at this point in the history
- This is then wrapped by DatetimeIndex.week
  • Loading branch information
mgmarino committed Apr 21, 2020
1 parent 0bda2e8 commit 658506d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1308,8 +1308,6 @@ def weekofyear(self):
weekofyear and week have been deprecated.
Please use DatetimeIndex.isocalendar().week instead.
"""
import pandas as pd

warnings.warn(
"weekofyear and week have been deprecated, please use "
"DatetimeIndex.isocalendar().week instead, which returns "
Expand All @@ -1319,7 +1317,10 @@ def weekofyear(self):
FutureWarning,
stacklevel=3,
)
return pd.Int64Index(self.isocalendar().week)
week_series = self.isocalendar().week
if week_series.hasnans:
return week_series.to_numpy(dtype="float64", na_value=np.nan)
return week_series.to_numpy(dtype="int64")

week = weekofyear

Expand Down

0 comments on commit 658506d

Please sign in to comment.