code: def kruskal(data=None, dv=None, between=None, detailed=False):
      """Kruskal-Wallis H-test for independent samples.
  
      Parameters
      ----------
      data : :py:class:`pandas.DataFrame`
          DataFrame
      dv : string
          Name of column containing the dependent variable.
      between : string
          Name of column containing the between factor.
  
      Returns
      -------
      stats : :py:class:`pandas.DataFrame`
  
          * ``'H'``: The Kruskal-Wallis H statistic, corrected for ties
          * ``'p-unc'``: Uncorrected p-value
          * ``'dof'``: degrees of freedom
  
      Notes
      -----
      The Kruskal-Wallis H-test tests the null hypothesis that the population
      median of all of the groups are equal. It is a non-parametric version of
      ANOVA. The test works on 2 or more independent samples, which may have
      different sizes.
  
      Due to the assumption that H has a chi square distribution, the number of
      samples in each group must not be too small. A typical rule is that each
      sample must have at least 5 measurements.
  
      NaN values are automatically removed.
  
      Examples
      --------
      Compute the Kruskal-Wallis H-test for independent samples.
  
      >>> from pingouin import kruskal, read_dataset
      >>> df = read_dataset('anova')
      >>> kruskal(data=df, dv='Pain threshold', between='Hair color')
                   Source  ddof1         H     p-unc
      Kruskal  Hair color      3  10.58863  0.014172
      """
      # Check data
      data = _check_dataframe(
          dv=dv, between=between, data=data, effects="between"
      )
  
      # Remove NaN values
      data = data[[dv, between]].dropna()
  
      # Reset index (avoid duplicate axis error)
      data = data.reset_index(drop=True)
  
      # Extract number of groups and total sample size
      n_groups = data[between].nunique()
      n = data[dv].size
  
      # Rank data, dealing with ties appropriately
      data["rank"] = scipy.stats.rankdata(data[dv])
  
      # Find the total of rank per groups
      grp = data.groupby(between, observed=True)["rank"]
      sum_rk_grp = grp.sum().to_numpy()
      n_per_grp = grp.count().to_numpy()
  
      # Calculate chi-square statistic (H)
      H = (
          12 / (n * (n + 1)) * np.sum(sum_rk_grp**2 / n_per_grp)
      ) - 3 * (n + 1)
  
      # Correct for ties
      H /= scipy.stats.tiecorrect(data["rank"].to_numpy())
  
      # Calculate DOF and p-value
      ddof1 = n_groups - 1
      p_unc = scipy.stats.chi2.sf(H, ddof1)
  
      # Create output dataframe
      stats = pd.DataFrame(
          {
              "Source": between,
              "ddof1": ddof1,
              "H": H,
              "p-unc": p_unc,
          },
          index=["Kruskal"],
      )
      return _postprocess_dataframe(stats)
  
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 5 for calling a global function with example usage: kruskal(data, dv, between, detailed) and returns: _postprocess_dataframe