psychopy_ext.stats.reorder

psychopy_ext.stats.reorder(agg, order, level=None, dim='columns')[source]

Reorders rows or columns in a pandas.DataFrame.

It relies on for loops, so it will be slow for large data frames.

Args:
  • agg (pandas.DataFrame)

    Your (usually aggregated) data

  • order (list or dict)

    Order of entries. A list is only accepted is level is given. Otherwise, order should be a dict with level names (str) as keys and a list of order in values.

Kwargs:
  • level (str, default: None)

    Which level needs to be reordered. Levels must be str.

  • dim (str, {‘rows’, ‘index’, ‘columns’}, default: ‘columns’)

    Whether to reorder rows (or index) or columns.

Returns:

Reordered pandas.DataFrame