code: def temporal_derivatives(order, variables, data):
      
      variables_deriv = OrderedDict()
      data_deriv = OrderedDict()
      if 0 in order:
          data_deriv[0] = data[variables]
          variables_deriv[0] = variables
          order = set(order) - set([0])
      for o in order:
          variables_deriv[o] = ['{}_derivative{}'.format(v, o)
                                for v in variables]
          data_deriv[o] = np.tile(np.nan, data[variables].shape)
          data_deriv[o][o:, :] = np.diff(data[variables], n=o, axis=0)
      variables_deriv = reduce((lambda x, y: x + y), variables_deriv.values())
      data_deriv = pd.DataFrame(columns=variables_deriv,
                                data=np.concatenate([*data_deriv.values()],
                                                    axis=1))
  
      return (variables_deriv, data_deriv)
docs: Compute temporal derivative terms by the method of backwards differences.
  
      Parameters
      ----------
      order: range or list(int)
          A list of temporal derivative terms to include. For instance, [1, 2]
          indicates that the first and second derivative terms should be added.
          To retain the original terms, 0 *must* be included in the list.
      variables: list(str)
          List of variables for which temporal derivative terms should be
          computed.
      data: pandas DataFrame object
          Table of values of all observations of all variables.
  
      Returns
      -------
      variables_deriv: list
          A list of variables to include in the final data frame after adding
          the specified derivative terms.
      data_deriv: pandas DataFrame object
          Table of values of all observations of all variables, including any
          specified derivative terms.