# 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('36c32818-0884-4e4f-90e1-d6f3ad713265','aa933765-d5bd-4b5f-bcc9-2b99db7ad45a','820609d9-7550-4f49-9458-7079509302c0','../lite/tree/../notebooks/index.html?path=dfc4b308_cfde_4f6e_9cd7_a5e988f0f380.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="820609d9-7550-4f49-9458-7079509302c0" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('36c32818-0884-4e4f-90e1-d6f3ad713265','820609d9-7550-4f49-9458-7079509302c0')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('36c32818-0884-4e4f-90e1-d6f3ad713265','820609d9-7550-4f49-9458-7079509302c0')">Open In Tab</button></div><div id="aa933765-d5bd-4b5f-bcc9-2b99db7ad45a" 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`   |    |
|-------------|----|
