metobs_toolkit.analysis.Analysis.aggregate_df#

Analysis.aggregate_df(df=None, agg=['lcz', 'hour'], method='mean')[source]#

Aggregate observations to a (list of) categories.

The output will be a dataframe that is aggregated to one, or more categories. A commen example is aggregating to LCZ’s.

Parameters:
  • df (pandas.DataFrame or None) – The observations to aggregate. If None, the df attribute of the Analysis instance is used. The default is None.

  • agg (list, optional) – The list of columnnames to aggregate to. If ‘lcz’ is included, the lcz information is extracted from the Analysis.metadf. The default is [‘lcz’, ‘datetime’].

  • method (str, optional) – list of functions and/or function names, e.g. [np.sum, ‘mean’]. The default is ‘mean’.

Returns:

A dataframe with the agg columns as an index. The values are the aggregated values.

Return type:

pandas.DataFrame

Note

Present columns that ar non-numeric and are not in the agg list, are not present in the return, since these values cannot be aggregated.