lisa.datautils.df_add_delta#

lisa.datautils.df_add_delta(df, col='delta', src_col=None, window=None, inplace=False)[source]#

Add a column containing the delta of the given other column.

Parameters:
  • df (pandas.DataFrame) – The dataframe to act on.

  • col (str) – The name of the column to add.

  • src_col (str or None) – Name of the column to compute the delta of. If None, the index is used.

  • window (tuple(float or None, float or None) or None) – Optionally, a window. It will be used to compute the correct delta of the last row. If inplace=False, the dataframe will be pre-filtered using df_refit_index(). This implies that the last row will have a NaN delta, but will be suitable e.g. for plotting, and aggregation functions that ignore delta such as pandas.DataFrame.sum().

  • inplace (bool) – If True, df is modified inplace to add the column