@@ -89,7 +89,7 @@ items and with the `slice` object:
89
89
90
90
.. ipython :: python
91
91
92
- time = pd.date_range(" 2000-01-01" , freq = " H " , periods = 365 * 24 )
92
+ time = pd.date_range(" 2000-01-01" , freq = " h " , periods = 365 * 24 )
93
93
ds = xr.Dataset({" foo" : (" time" , np.arange(365 * 24 )), " time" : time})
94
94
ds.sel(time = " 2000-01" )
95
95
ds.sel(time = slice (" 2000-06-01" , " 2000-06-10" ))
@@ -115,7 +115,7 @@ given ``DataArray`` can be quickly computed using a special ``.dt`` accessor.
115
115
116
116
.. ipython :: python
117
117
118
- time = pd.date_range(" 2000-01-01" , freq = " 6H " , periods = 365 * 4 )
118
+ time = pd.date_range(" 2000-01-01" , freq = " 6h " , periods = 365 * 4 )
119
119
ds = xr.Dataset({" foo" : (" time" , np.arange(365 * 4 )), " time" : time})
120
120
ds.time.dt.hour
121
121
ds.time.dt.dayofweek
@@ -207,7 +207,7 @@ For example, we can downsample our dataset from hourly to 6-hourly:
207
207
.. ipython :: python
208
208
:okwarning:
209
209
210
- ds.resample(time = " 6H " )
210
+ ds.resample(time = " 6h " )
211
211
212
212
This will create a specialized ``Resample `` object which saves information
213
213
necessary for resampling. All of the reduction methods which work with
@@ -216,21 +216,21 @@ necessary for resampling. All of the reduction methods which work with
216
216
.. ipython :: python
217
217
:okwarning:
218
218
219
- ds.resample(time = " 6H " ).mean()
219
+ ds.resample(time = " 6h " ).mean()
220
220
221
221
You can also supply an arbitrary reduction function to aggregate over each
222
222
resampling group:
223
223
224
224
.. ipython :: python
225
225
226
- ds.resample(time = " 6H " ).reduce(np.mean)
226
+ ds.resample(time = " 6h " ).reduce(np.mean)
227
227
228
228
You can also resample on the time dimension while applying reducing along other dimensions at the same time
229
229
by specifying the `dim ` keyword argument
230
230
231
231
.. code-block :: python
232
232
233
- ds.resample(time = " 6H " ).mean(dim = [" time" , " latitude" , " longitude" ])
233
+ ds.resample(time = " 6h " ).mean(dim = [" time" , " latitude" , " longitude" ])
234
234
235
235
For upsampling, xarray provides six methods: ``asfreq ``, ``ffill ``, ``bfill ``, ``pad ``,
236
236
``nearest `` and ``interpolate ``. ``interpolate `` extends ``scipy.interpolate.interp1d ``
@@ -243,7 +243,7 @@ Data that has indices outside of the given ``tolerance`` are set to ``NaN``.
243
243
244
244
.. ipython :: python
245
245
246
- ds.resample(time = " 1H " ).nearest(tolerance = " 1H " )
246
+ ds.resample(time = " 1h " ).nearest(tolerance = " 1h " )
247
247
248
248
249
249
For more examples of using grouped operations on a time dimension, see
0 commit comments