docstr: Extract variables from data or use directly.
docstr_tok: ["Extract","variables","from","data","or","use","directly","."]
code: def format_data(
      self, data, pivot_kws, z_score=None, standard_scale=None
  ):
      """Extract variables from data or use directly."""
  
      # Either the data is already in 2d matrix format, or need to do a pivot
      if pivot_kws is not None:
          data2d = data.pivot(**pivot_kws)
      else:
          data2d = data
  
      if z_score is not None and standard_scale is not None:
          raise ValueError(
              "Cannot perform both z-scoring and standard-scaling on data"
          )
  
      if z_score is not None:
          data2d = self.z_score(data2d, z_score)
      if standard_scale is not None:
          data2d = self.standard_scale(data2d, standard_scale)
      return data2d
  
imports: import warnings
  import matplotlib
  from matplotlib.collections import LineCollection
  import matplotlib.pyplot
  from matplotlib import gridspec
  import numpy
  import pandas
  from .None import cm
  from .axisgrid import Grid
  from ._compat import get_colormap
  from .utils import despine, axis_ticklabels_overlap, relative_luminance, to_utf8, _draw_figure
label_desc: Use image node_id 3 for calling the ClusterGrid obj's underlying member method code with example usage: obj.format_data(data, pivot_kws, z_score, standard_scale) and returns: data2d