metobs_toolkit.analysis.Analysis.get_anual_statistics#

Analysis.get_anual_statistics(groupby=['name'], obstype='temp', agg_method='mean', stations=None, startdt=None, enddt=None, plot=True, errorbands=False, title=None, y_label=None, legend=True, _return_all_stats=False)[source]#

Create an anual cycle for aggregated groups.

(In the plot, unique combination of groupby categories is presented

as a line.)

Parameters:
  • groupby (list string, optional) – Variables to aggregate to. These can be columns in the metadf, or time aggregations (‘hour’, ‘year’, ‘week_of_year’, …]. ‘name’ will aggregate to the stationnames. The default is [‘name’].

  • obstype (str, optional) – Element of the metobs_toolkit.observation_types The default is ‘temp’.

  • agg_method (str, optional) – Function names to use for aggregation, e.g. [np.sum, ‘mean’]. The default is ‘mean’.

  • stations (list, optional) – List of station names to use. If None, all present stations will be used. The default is None.

  • startdt (datetime.datetime, optional) – The start datetime of the observations to use. If None, all timestamps will be used. The default is None.

  • enddt (datetime.datetime, optional) – The end datetime of the observations to use. If None, all timestamps will be used. The default is None.

  • plot (bool, optional) – If True, an anual plot is made. The default is True.

  • errorbands (bool, optional) – If True, the std is representd in the plot by colored bands. The default is False.

  • title (string, optional) – Title of the figure, if None a default title is generated. The default is None.

  • y_label (string, optional) – y-axes label of the figure, if None a default label is generated. The default is None.

  • legend (bool, optional) – I True, a legend is added to the plot. The default is True.

Returns:

df – The dataframe containing the aggregated values.

Return type:

pandas.DataFrame()

Note

If a timezone unaware datetime is given as an argument, it is interpreted as if it has the same timezone as the observations.