lair.clock.diurnal#

lair.clock.diurnal(data, freq='1h', statistic='mean', method='floor')[source]#

Aggregate the data to the specified frequency and compute the statistic for each group.

Parameters:
  • data (pd.DataFrame) – The data to aggregate. Panda DataFrame with a DateTimeIndex.

  • freq (str) – The frequency to aggregate the data to. Sub-Daily.

  • statistic (str or list of str, optional) – The statistic to compute for each group. Default is ‘mean’.

  • method (one of 'floor', 'ceil', 'round') – The method to use to round the index to the nearest freq.

Returns:

pd.DataFrame – The aggregated data, indexed by the time of day.

See also

seasonal

Aggregates by season and year.

Examples

The mean of two days of hourly data at each hour of the day:

>>> import numpy as np
>>> import pandas as pd
>>> from lair.clock import diurnal
>>> times = pd.date_range("2024-01-01", periods=48, freq="h")
>>> data = pd.DataFrame({"ch4": np.arange(48.0)}, index=times)
>>> diurnal(data).head(2)
           ch4
00:00:00  12.0
01:00:00  13.0