code: def diag_stressor(self, stressor, name=None):
          
          if type(stressor) is int:
              stressor = self.F.index[stressor]
          if len(stressor) == 1:
              stressor = stressor[0]
          if not name:
              if type(stressor) is str:
                  name = stressor
              else:
                  name = '_'.join(stressor) + '_diag'
  
          ext_diag = Extension(name)
  
          ext_diag.F = pd.DataFrame(
                  index=self.F.columns,
                  columns=self.F.columns,
                  data=np.diag(self.F.loc[stressor, :])
                  )
          try:
              ext_diag.unit = pd.DataFrame(
                      index=ext_diag.F.index,
                      columns=self.unit.columns,
                      data=self.unit.loc[stressor].unit)
          except AttributeError:
              # If no unit in stressor, self.unit.columns break
              ext_diag.unit = None
  
          return ext_diag
docs: Diagonalize one row of the stressor matrix for a flow analysis.
  
          This method takes one row of the F matrix and diagonalize
          to the full region/sector format. Footprints calculation based
          on this matrix show the flow of embodied stressors from the source
          region/sector (row index) to the final consumer (column index).
  
          Note
          ----
  
          Since the type of analysis based on the disaggregated matrix is based
          on flow, direct household emissions (FY) are not included.
  
          Parameters
          ----------
          stressor : str or int - valid index for one row of the F matrix
              This must be a tuple for a multiindex, a string otherwise.
              The stressor to diagonalize.
  
          name : string (optional)
              The new name for the extension,
              if None (default): string based on the given stressor (row name)
  
          Returns
          -------
          Extension