# xarray.groupers.SeasonGrouper

### *class* xarray.groupers.SeasonGrouper(seasons)[[source]](https://github.com/pydata/xarray/blob/main/xarray/groupers.py#L806-L878)

Allows grouping using a custom definition of seasons.

* **Parameters:**
  **seasons** ([sequence](https://docs.python.org/3/glossary.html#term-sequence) of [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – List of strings representing seasons. E.g. `"JF"` or `"JJA"` etc.
  Overlapping seasons are allowed (e.g. `["DJFM", "MAMJ", "JJAS", "SOND"]`)

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('ff261daa-63cd-4bd1-813b-783f43df2489','79fa1bb4-17f3-4c20-bb69-99855c28b58b','60e8a4b8-65c2-47e0-b452-1f45a447768f','../lite/tree/../notebooks/index.html?path=f581f0f7_d3a9_4dcf_a13f_38b33d561780.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> SeasonGrouper(["JF", "MAM", "JJAS", "OND"])
SeasonGrouper(seasons=['JF', 'MAM', 'JJAS', 'OND'])
```

The ordering is preserved

```pycon
>>> SeasonGrouper(["MAM", "JJAS", "OND", "JF"])
SeasonGrouper(seasons=['MAM', 'JJAS', 'OND', 'JF'])
```

Overlapping seasons are allowed

```pycon
>>> SeasonGrouper(["DJFM", "MAMJ", "JJAS", "SOND"])
SeasonGrouper(seasons=['DJFM', 'MAMJ', 'JJAS', 'SOND'])
```

<div id="60e8a4b8-65c2-47e0-b452-1f45a447768f" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('ff261daa-63cd-4bd1-813b-783f43df2489','60e8a4b8-65c2-47e0-b452-1f45a447768f')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('ff261daa-63cd-4bd1-813b-783f43df2489','60e8a4b8-65c2-47e0-b452-1f45a447768f')">Open In Tab</button></div><div id="79fa1bb4-17f3-4c20-bb69-99855c28b58b" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>

#### \_\_init_\_(seasons)[[source]](https://github.com/pydata/xarray/blob/main/xarray/../doc/<string>)

### Methods

| [`__init__`](#xarray.groupers.SeasonGrouper.__init__)(seasons)   |                                                            |
|----------------------------------------------------------------------|------------------------------------------------------------|
| `factorize`(group)                                                   | Creates intermediates necessary for GroupBy.               |
| `reset`()                                                            | Creates a new version of this Grouper clearing any caches. |

### Attributes

| `seasons`   |    |
|-------------|----|
