# psychopy_ext.stats.aggregate

`psychopy_ext.stats.``aggregate`(df, rows=None, cols=None, values=None, subplots=None, yerr=None, aggfunc='mean', unstacked=False, order='natural')

  Aggregates data over specified columns.

  Args: | df (pandas.DataFrame) A DataFrame with your data
  Kwargs: | rows (str or list of str, default: None) Name(s) of column(s) that will be aggregated and plotted on the x-axis cols (str or list of str, default: None) Name(s) of column(s) that will be shown in the legend values (str or list of str, default: None) Name(s) of the column(s) that is aggregated yerr (str, default: None) Name of the column for the y-errorbar calculation. Typically, this is the column with participant IDs. aggfunc (str or a 1d function) A function to use for aggregation. If a string, it is interpreted as a numpy function. unstacked (bool, default: False) If True, returns an unstacked version of aggregated data (i.e., rows in rows and columns in columns)). Useful for printing and other non-plotting tasks. order (str, {‘natural’, ‘sorted’}, default: ‘natural’) If order is ‘natural’, attempts to keep the original order of the data (as in the file). Works only sometimes though. If ‘sorted’, then will come out sorted as is by default in pandas.
  Returns: | A pandas.DataFrame where data has been aggregated in the following MultiIndex format: - columns: level 0: subplots level 1 to n-2: rows level n-1: column rows: yerr This format makes it easy to do further computations such as mean over yerr: a simple df.mean() will do the trick.
  See also: | `accuracy()`