code: def mad(a, normalize=True, axis=0):
      """
      Median Absolute Deviation (MAD) along given axis of an array.
  
      Parameters
      ----------
      a : array-like
          Input array.
      normalize : boolean.
          If True, scale by a normalization constant :math:`c \\approx  0.67`
          to ensure consistency with the standard deviation for normally
          distributed data.
      axis : int or None, optional
          Axis along which the MAD is computed. Default is 0.
          Can also be None to compute the MAD over the entire array.
  
      Returns
      -------
      mad : float
          mad = median(abs(a - median(a))) / c
  
      See also
      --------
      madmedianrule, numpy.std
  
      Notes
      -----
      The `median absolute deviation
      <https://en.wikipedia.org/wiki/Median_absolute_deviation>`_ (MAD) computes
      the median over the absolute deviations from the median. It is a measure of
      dispersion similar to the standard deviation, but is more robust to
      outliers.
  
      SciPy 1.3 and higher includes a similar function:
      :py:func:`scipy.stats.median_abs_deviation`.
  
      Please note that missing values are automatically removed.
  
      Examples
      --------
      >>> from pingouin import mad
      >>> a = [1.2, 5.4, 3.2, 7.8, 2.5]
      >>> mad(a)
      2.965204437011204
  
      >>> mad(a, normalize=False)
      2.0
  
      2D arrays with missing values (axis handling example)
  
      >>> import numpy as np
      >>> np.random.seed(123)
      >>> w = np.random.normal(size=(5, 10))
      >>> w[3, 2] = np.nan
      >>> mad(w)  # Axis = 0 (default) = iterate over the columns
      array([0.60304023, 2.35057834, 0.90350696, 1.28599837, 1.16024152,
             0.38653752, 1.92564066, 1.2480913 , 0.42580373, 1.69814622])
  
      >>> mad(w, axis=1)  # Axis = 1 = iterate over the rows
      array([1.32639022, 1.19295036, 1.41198672, 0.78020689, 1.01531254])
  
      >>> mad(w, axis=None)  # Axis = None = over the entire array
      1.1607762457644006
  
      Compare with Scipy >= 1.3
  
      >>> from scipy.stats import median_abs_deviation
      >>> median_abs_deviation(w, scale='normal', axis=None, nan_policy='omit')
      1.1607762457644006
      """
      a = np.asarray(a)
      if axis is None:
          # Calculate the MAD over the entire array
          a = np.ravel(a)
          axis = 0
      c = scipy.stats.norm.ppf(3 / 4.0) if normalize else 1
      center = np.apply_over_axes(np.nanmedian, a, axis)
      return np.nanmedian((np.fabs(a - center)) / c, axis=axis)
  
file_path: pingouin/pingouin/nonparametric.py
imports: import scipy
  import numpy
  import pandas
  from pingouin import remove_na, _check_dataframe, _postprocess_dataframe
label_desc: Use image node_id 1 for calling a global function with example usage: mad(a, normalize, axis) and returns: np