@@ -88,7 +88,22 @@ For more details, read the pandas documentation.
8888Datetime components
8989-------------------
9090
91- xarray supports a notion of "virtual" or "derived" coordinates for
91+ Similar `to pandas `_, the components of datetime objects contained in a
92+ given ``DataArray `` can be quickly computed using a special ``.dt `` accessor.
93+
94+ .. _to pandas : http://pandas.pydata.org/pandas-docs/stable/basics.html#basics-dt-accessors
95+
96+ .. ipython :: python
97+
98+ time = time = pd.date_range(' 2000-01-01' , freq = ' 6H' , periods = 365 * 4 )
99+ ds = xr.Dataset({' foo' : (' time' , np.arange(365 * 24 )), ' time' : time})
100+ ds.time.dt.hour
101+ ds.time.dt.dayofweek
102+
103+ The ``.dt `` accessor works on both coordinate dimensions as well as
104+ multi-dimensional data.
105+
106+ xarray also supports a notion of "virtual" or "derived" coordinates for
92107`datetime components `__ implemented by pandas, including "year", "month",
93108"day", "hour", "minute", "second", "dayofyear", "week", "dayofweek", "weekday"
94109and "quarter":
@@ -100,7 +115,8 @@ __ http://pandas.pydata.org/pandas-docs/stable/api.html#time-date-components
100115 ds[' time.month' ]
101116 ds[' time.dayofyear' ]
102117
103- xarray adds ``'season' `` to the list of datetime components supported by pandas:
118+ For use as a derived coordinate, xarray adds ``'season' `` to the list of
119+ datetime components supported by pandas:
104120
105121.. ipython :: python
106122
@@ -124,7 +140,7 @@ calculate the mean by time of day:
124140
125141 For upsampling or downsampling temporal resolutions, xarray offers a
126142:py:meth: `~xarray.Dataset.resample ` method building on the core functionality
127- offered by the pandas method of the same name. Resample uses essentialy the
143+ offered by the pandas method of the same name. Resample uses essentially the
128144same api as ``resample `` `in pandas `_.
129145
130146.. _in pandas : http://pandas.pydata.org/pandas-docs/stable/timeseries.html#up-and-downsampling
0 commit comments