code: def frequency_analysis(da, mode, t, dist, window=1, freq=None, **indexer):
      
      # Apply rolling average
      if window > 1:
          da = da.rolling(time=window, center=False).mean()
  
      # Assign default resampling frequency if not provided
      freq = freq or default_freq(**indexer)
  
      # Extract the time series of min or max over the period
      sel = select_resample_op(da, op=mode, freq=freq, **indexer).dropna(dim='time')
  
      # Frequency analysis
      return fa(sel, t, dist, mode)
docs: Return the value corresponding to a return period.
  
      Parameters
      ----------
      da : xarray.DataArray
        Input data.
      t : int or sequence
        Return period. The period depends on the resolution of the input data. If the input array's resolution is
        yearly, then the return period is in years.
      dist : str
        Name of the univariate distribution, such as beta, expon, genextreme, gamma, gumbel_r, lognorm, norm
        (see scipy.stats).
      mode : {'min', 'max'}
        Whether we are looking for a probability of exceedance (high) or a probability of non-exceedance (low).
      window : int
        Averaging window length (days).
      freq : str
        Resampling frequency. If None, the frequency is assumed to be 'YS' unless the indexer is season='DJF',
        in which case `freq` would be set to `YS-DEC`.
      **indexer : {dim: indexer, }, optional
        Time attribute and values over which to subset the array. For example, use season='DJF' to select winter values,
        month=1 to select January, or month=[6,7,8] to select summer months. If not indexer is given, all values are
        considered.
  
      Returns
      -------
      xarray.DataArray
        An array of values with a 1/t probability of exceedance or non-exceedance when mode is high or low respectively.