docs: def assign_norrec_diffs(df, diff_list):
      """Compute and write the difference between normal and reciprocal values
      for all columns specified in the diff_list parameter.
  
      Note that the DataFrame is directly written to. That is, it is changed
      during the call of this function. No need to use the returned object.
  
      Parameters
      ----------
      df: pandas.DataFrame
          Dataframe containing the data
      diff_list: list
          list of columns to compute differences for.
  
      Returns
      -------
      df_new: pandas.DataFrame
          The data with added columns
      """
      extra_dims = [
          x for x in ('timestep', 'frequency', 'id') if x in df.columns
      ]
      g = df.groupby(extra_dims)
  
      def subrow(row):
          if row.size == 2:
              return row.iloc[1] - row.iloc[0]
          else:
              return np.nan
  
      for diffcol in diff_list:
          diff = g[diffcol].agg(subrow).reset_index()
          # rename the column
          cols = list(diff.columns)
          cols[-1] = diffcol + 'diff'
          diff.columns = cols
  
          df = df.drop(
              cols[-1], axis=1, errors='ignore'
          ).merge(diff, on=extra_dims, how='outer')
  
      df = df.sort_values(extra_dims)
      return df