# xarray.groupers.TimeResampler

### *class* xarray.groupers.TimeResampler(freq, closed=None, label=None, origin='start_day', offset=None)[[source]](https://github.com/pydata/xarray/blob/main/xarray/groupers.py#L477-L644)

Grouper object specialized to resampling the time coordinate.

#### freq

Frequency to resample to. See [Pandas frequency
aliases](https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases)
for a list of possible values.

* **Type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`datetime.timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta), [`pandas.Timestamp`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Timestamp.html#pandas.Timestamp), or [`pandas.DateOffset`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.tseries.offsets.DateOffset.html#pandas.tseries.offsets.DateOffset)

#### closed

Side of each interval to treat as closed.

* **Type:**
  `{"left", "right"}`, *optional*

#### label

Side of each interval to use for labeling.

* **Type:**
  `{"left", "right"}`, *optional*

#### origin

The datetime on which to adjust the grouping. The timezone of origin
must match the timezone of the index.

If a datetime is not used, these values are also supported:
- ‘epoch’: origin is 1970-01-01
- ‘start’: origin is the first value of the timeseries
- ‘start_day’: origin is the first day at midnight of the timeseries
- ‘end’: origin is the last value of the timeseries
- ‘end_day’: origin is the ceiling midnight of the last day

* **Type:**
  `{'epoch', 'start', 'start_day', 'end', 'end_day'}`, [`pandas.Timestamp`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Timestamp.html#pandas.Timestamp), [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime), [`numpy.datetime64`](https://numpy.org/doc/stable/reference/arrays.scalars.html#numpy.datetime64), or [`cftime.datetime`](https://unidata.github.io/cftime/api.html#cftime.datetime), *default* `'start_day'`

#### offset

An offset timedelta added to the origin.

* **Type:**
  `pd.Timedelta`, [`datetime.timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta), or [`str`](https://docs.python.org/3/builtins/stdtypes.html#str), *default* `is None`

#### \_\_init_\_(freq, closed=None, label=None, origin='start_day', offset=None)[[source]](https://github.com/pydata/xarray/blob/main/xarray/../doc/<string>)

### Methods

| [`__init__`](#xarray.groupers.TimeResampler.__init__)(freq[, closed, label, origin, offset])                                |                                                            |
|---------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------|
| [`compute_chunks`](xarray.groupers.TimeResampler.compute_chunks.html.md#xarray.groupers.TimeResampler.compute_chunks)(variable, \*, dim) | Compute chunk sizes for this time resampler.               |
| `factorize`(group)                                                                                                              | Creates intermediates necessary for GroupBy.               |
| `first_items`()                                                                                                                 |                                                            |
| `reset`()                                                                                                                       | Creates a new version of this Grouper clearing any caches. |

### Attributes

| [`closed`](#xarray.groupers.TimeResampler.closed)   |    |
|-----------------------------------------------------------|----|
| [`label`](#xarray.groupers.TimeResampler.label)    |    |
| [`offset`](#xarray.groupers.TimeResampler.offset)   |    |
| [`origin`](#xarray.groupers.TimeResampler.origin)   |    |
| [`freq`](#xarray.groupers.TimeResampler.freq)     |    |
| `index_grouper`                                           |    |
| `group_as_index`                                          |    |
