1616 is_np_timedelta_like ,
1717)
1818from xarray .core .types import T_DataArray
19+ from xarray .core .utils import emit_user_level_warning
1920from xarray .core .variable import IndexVariable , Variable
2021from xarray .namedarray .utils import is_duck_dask_array
2122
@@ -338,8 +339,8 @@ class DatetimeAccessor(TimeAccessor[T_DataArray]):
338339 * time (time) datetime64[us] 80B 2000-01-01 2000-01-02 ... 2000-01-10
339340 >>> ts.dt # doctest: +ELLIPSIS
340341 <xarray.core.accessor_dt.DatetimeAccessor object at 0x...>
341- >>> ts.dt.dayofyear
342- <xarray.DataArray 'dayofyear ' (time: 10)> Size: 80B
342+ >>> ts.dt.day_of_year
343+ <xarray.DataArray 'day_of_year ' (time: 10)> Size: 80B
343344 array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
344345 Coordinates:
345346 * time (time) datetime64[us] 80B 2000-01-01 2000-01-02 ... 2000-01-10
@@ -465,17 +466,45 @@ def weekofyear(self) -> DataArray:
465466
466467 week = weekofyear
467468
469+ @property
470+ def day_of_week (self ) -> T_DataArray :
471+ """The day of the week with Monday=0, Sunday=6"""
472+ return self ._date_field ("day_of_week" , np .int64 )
473+
468474 @property
469475 def dayofweek (self ) -> T_DataArray :
470476 """The day of the week with Monday=0, Sunday=6"""
471- return self ._date_field ("dayofweek" , np .int64 )
477+ emit_user_level_warning (
478+ "dt.dayofweek is deprecated and will be removed in a future "
479+ "version. Use dt.day_of_week instead." ,
480+ FutureWarning ,
481+ )
482+ return self ._date_field ("day_of_week" , np .int64 )
472483
473- weekday = dayofweek
484+ @property
485+ def weekday (self ) -> T_DataArray :
486+ """The day of the week with Monday=0, Sunday=6"""
487+ emit_user_level_warning (
488+ "dt.weekday is deprecated and will be removed in a "
489+ "future version. Use dt.day_of_week instead." ,
490+ FutureWarning ,
491+ )
492+ return self ._date_field ("day_of_week" , np .int64 )
493+
494+ @property
495+ def day_of_year (self ) -> T_DataArray :
496+ """The ordinal day of the year"""
497+ return self ._date_field ("day_of_year" , np .int64 )
474498
475499 @property
476500 def dayofyear (self ) -> T_DataArray :
477501 """The ordinal day of the year"""
478- return self ._date_field ("dayofyear" , np .int64 )
502+ emit_user_level_warning (
503+ "dt.dayofyear is deprecated and will be removed in a future "
504+ "version. Use dt.day_of_year instead." ,
505+ FutureWarning ,
506+ )
507+ return self ._date_field ("day_of_year" , np .int64 )
479508
480509 @property
481510 def quarter (self ) -> T_DataArray :
@@ -487,7 +516,15 @@ def days_in_month(self) -> T_DataArray:
487516 """The number of days in the month"""
488517 return self ._date_field ("days_in_month" , np .int64 )
489518
490- daysinmonth = days_in_month
519+ @property
520+ def daysinmonth (self ) -> T_DataArray :
521+ """The number of days in the month"""
522+ emit_user_level_warning (
523+ "dt.daysinmonth is deprecated and will be removed in a future "
524+ "version. Use dt.days_in_month instead." ,
525+ FutureWarning ,
526+ )
527+ return self ._date_field ("days_in_month" , np .int64 )
491528
492529 @property
493530 def season (self ) -> T_DataArray :
0 commit comments