File tree 5 files changed +26
-1
lines changed
5 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 287
287
core.accessor_dt.DatetimeAccessor.floor
288
288
core.accessor_dt.DatetimeAccessor.round
289
289
core.accessor_dt.DatetimeAccessor.strftime
290
+ core.accessor_dt.DatetimeAccessor.date
290
291
core.accessor_dt.DatetimeAccessor.day
291
292
core.accessor_dt.DatetimeAccessor.dayofweek
292
293
core.accessor_dt.DatetimeAccessor.dayofyear
Original file line number Diff line number Diff line change @@ -507,6 +507,7 @@ Datetimelike properties
507
507
DataArray.dt.daysinmonth
508
508
DataArray.dt.season
509
509
DataArray.dt.time
510
+ DataArray.dt.date
510
511
DataArray.dt.is_month_start
511
512
DataArray.dt.is_month_end
512
513
DataArray.dt.is_quarter_end
Original file line number Diff line number Diff line change @@ -51,12 +51,13 @@ New Features
51
51
grant from the `Chan Zuckerberg Initiative <https://chanzuckerberg.com >`_ and
52
52
developed by `B-Open <https://www.bopen.eu >`_.
53
53
By `Aureliana Barghini <https://github.com/aurghs >`_ and `Alessandro Amici <https://github.com/alexamici >`_.
54
+ - :py:attr: `~core.accessor_dt.DatetimeAccessor.date ` added (:issue: `4983 `, :pull: `4994 `).
55
+ By `Hauke Schulz <https://github.com/observingClouds >`_.
54
56
- Implement ``__getitem__ `` for both :py:class: `~core.groupby.DatasetGroupBy ` and
55
57
:py:class: `~core.groupby.DataArrayGroupBy `, inspired by pandas'
56
58
:py:meth: `~pandas.core.groupby.GroupBy.get_group `.
57
59
By `Deepak Cherian <https://github.com/dcherian >`_.
58
60
59
-
60
61
Breaking changes
61
62
~~~~~~~~~~~~~~~~
62
63
- :py:func: `open_dataset ` and :py:func: `open_dataarray ` now accept only the first argument
Original file line number Diff line number Diff line change @@ -31,6 +31,10 @@ def _access_through_cftimeindex(values, name):
31
31
if name == "season" :
32
32
months = values_as_cftimeindex .month
33
33
field_values = _season_from_months (months )
34
+ elif name == "date" :
35
+ raise AttributeError (
36
+ "'CFTimeIndex' object has no attribute `date`. Consider using the floor method instead, for instance: `.time.dt.floor('D')`."
37
+ )
34
38
else :
35
39
field_values = getattr (values_as_cftimeindex , name )
36
40
return field_values .reshape (values .shape )
@@ -415,6 +419,10 @@ def weekofyear(self):
415
419
"time" , "Timestamps corresponding to datetimes" , object
416
420
)
417
421
422
+ date = Properties ._tslib_field_accessor (
423
+ "date" , "Date corresponding to datetimes" , object
424
+ )
425
+
418
426
is_month_start = Properties ._tslib_field_accessor (
419
427
"is_month_start" ,
420
428
"Indicates whether the date is the first day of the month." ,
Original file line number Diff line number Diff line change @@ -59,6 +59,8 @@ def setup(self):
59
59
"weekday" ,
60
60
"dayofyear" ,
61
61
"quarter" ,
62
+ "date" ,
63
+ "time" ,
62
64
"is_month_start" ,
63
65
"is_month_end" ,
64
66
"is_quarter_start" ,
@@ -144,6 +146,8 @@ def test_not_datetime_type(self):
144
146
"weekday" ,
145
147
"dayofyear" ,
146
148
"quarter" ,
149
+ "date" ,
150
+ "time" ,
147
151
"is_month_start" ,
148
152
"is_month_end" ,
149
153
"is_quarter_start" ,
@@ -430,6 +434,16 @@ def test_isocalendar_cftime(data):
430
434
data .time .dt .isocalendar ()
431
435
432
436
437
+ @requires_cftime
438
+ def test_date_cftime (data ):
439
+
440
+ with raises_regex (
441
+ AttributeError ,
442
+ r"'CFTimeIndex' object has no attribute `date`. Consider using the floor method instead, for instance: `.time.dt.floor\('D'\)`." ,
443
+ ):
444
+ data .time .dt .date ()
445
+
446
+
433
447
@requires_cftime
434
448
@pytest .mark .filterwarnings ("ignore::RuntimeWarning" )
435
449
def test_cftime_strftime_access (data ):
You can’t perform that action at this time.
0 commit comments