dautil.ts

Utilities for time series and dates.

dautil.ts.ar1(arr)

Fits AR(1) model.

Parameters:arr – array-like, shape(M,)

:returns A dictionary with slope and intercept of the model.

dautil.ts.double_exp_smoothing(arr, alpha, beta)

Applies double exponential smoothing.

\[\begin{split}\begin{align} s_{t} = \alpha x_{t} + (1-\alpha)(s_{t-1} + b_{t-1})\\ b_{t} = \beta (s_t - s_{t-1}) + (1-\beta)b_{t-1}\\ \end{align}\end{split}\]
Parameters:
  • arr – Array-like list of values.
  • alpha – The smoothing factor parameter.
  • beta – The trend factor parameter.
Returns:

The smoothed series values.

dautil.ts.exp_smoothing(arr, alpha)

Applies exponential smoothing.

\[s_t = \alpha \cdot x_{t} + (1-\alpha) \cdot s_{t-1}\]
Parameters:
  • arr – Array-like list of values.
  • alpha – The smoothing factor parameter.
Returns:

The smoothed series values.

dautil.ts.fano_factor(arr, window)

Calculates the Fano factor a windowed variance-to-mean ratio.

\[F=\frac{\sigma_W^2}{\mu_W}\]
Parameters:
  • arr – Array-like list of values.
  • window – Size of the window.
Returns:

The Fano factor.

See Also

https://en.wikipedia.org/wiki/Fano_factor

dautil.ts.groupby_month(df)

Groups a pandas DataFrame by month.

Parameters:df – A pandas DataFrame.
Returns:The grouped DataFrame.
dautil.ts.groupby_yday(df)

Groups a pandas DataFrame by the day of year.

Parameters:df – A pandas DataFrame.
Returns:The grouped DataFrame.
dautil.ts.groupby_year(df)

Groups a pandas DataFrame by year.

Parameters:df – A pandas DataFrame.
Returns:The grouped DataFrame.
dautil.ts.groupby_year_month(df)

Groups a pandas DataFrame by year and month.

Parameters:df – A pandas DataFrame.
Returns:The grouped DataFrame.
dautil.ts.instant_phase(arr)

Computes the instaneous phase of a signal.

Parameters:arr – Array-like list of values.
Returns:The instaneous phase.
dautil.ts.month_index(month, zero_based=False)

Looks up the index of a month from a short name.

Parameters:
  • month – The short name of a month to lookup for example Jan.
  • zero_based – Indicates whether the index starts from 0.
Returns:

The index of the month.

>>> from dautil import ts
>>> ts.month_index('Jan')
1
dautil.ts.power(arr)

Computes the power of a signal.

Parameters:arr – Array-like list of values.
Returns:The power of a signal.
dautil.ts.rolling_deviations(arr, window)

Computes the rolling deviations of a series, by subtracting the rolling mean and dividing by the rolling standard deviation.

Parameters:
  • arr – Array-like list of values.
  • window – Size of the window.
Returns:

The rolling deviations.

dautil.ts.short_month(i, zero_based=False)

Looks up the short name of a month with an index.

Parameters:
  • i – Index of the month to lookup.
  • zero_based – Indicates whether the index starts from 0.
Returns:

The short name of the month for example Jan.

>>> from dautil import ts
>>> ts.short_month(1)
'Jan'
dautil.ts.short_months()

Gets the short names of the months.

Returns:A list containing the short month names.
dautil.ts.sine_like(arr)

Creates a sine wave of roughly the same size as the input.

Parameters:arr – Array-like list of values.
Returns:A sine wave.

Previous topic

dautil.stats

Next topic

dautil.web

This Page