code: def _check_dataframe(
      data=None,
      dv=None,
      between=None,
      within=None,
      subject=None,
      effects=None,
  ):
      """Checks whether data is a dataframe or can be converted to a dataframe.
      If successful, a dataframe is returned. If not successful, a ValueError is
      raised.
      """
      # Check that data is a dataframe
      if not isinstance(data, pd.DataFrame):
          # DataMatrix objects can be safely convert to DataFrame objects. By
          # first checking the name of the class, we avoid having to actually
          # import DataMatrix unless it is necessary.
          if data.__class__.__name__ == "DataMatrix":  # noqa
              try:
                  from datamatrix import (
                      DataMatrix,
                      convert as cnv,
                  )  # noqa
              except ImportError:
                  raise ValueError(
                      "Failed to convert object to pandas dataframe (DataMatrix not available)"  # noqa
                  )
              else:
                  if isinstance(data, DataMatrix):
                      data = cnv.to_pandas(data)
                  else:
                      raise ValueError(
                          "Data must be a pandas dataframe or compatible object."
                      )
          else:
              raise ValueError(
                  "Data must be a pandas dataframe or compatible object."
              )
      # Check that both dv and data are provided.
      if any(v is None for v in [dv, data]):
          raise ValueError("DV and data must be specified")
      # Check that dv is a numeric variable
      if data[dv].dtype.kind not in "fi":
          raise ValueError("DV must be numeric.")
      # Check that effects is provided
      if effects not in ["within", "between", "interaction", "all"]:
          raise ValueError(
              "Effects must be: within, between, interaction, all"
          )
      # Check that within is a string, int or a list (rm_anova2)
      if effects == "within" and not isinstance(
          within, (str, int, list)
      ):
          raise ValueError("within must be a string, int or a list.")
      # Check that subject identifier is provided in rm_anova and friedman.
      if effects == "within" and subject is None:
          raise ValueError(
              "subject must be specified when effects=within"
          )
      # Check that between is a string or a list (anova2)
      if effects == "between" and not isinstance(
          between, (str, int, list)
      ):
          raise ValueError("between must be a string, int or a list.")
      # Check that both between and within are present for interaction
      if effects == "interaction":
          for input in [within, between]:
              if not isinstance(input, (str, int, list)):
                  raise ValueError(
                      "within and between must be specified when effects=interaction"
                  )
      return data
  
file_path: pingouin/pingouin/utils.py
imports: import numbers
  import numpy
  import pandas
  import itertools
  import collections.abc
  from tabulate import tabulate
  from .config import options
label_desc: Use image node_id 9 for calling a global function with example usage: _check_dataframe(data, dv, between, within, subject, effects) and returns: data