code: def data_stats(
      X: pd.DataFrame, categorical_mask: Iterable[bool]
  ) -> List[Tuple[str, str, float, bool]]:
      """Computes data statistics on instances.
  
      Args:
          X (pd.DataFrame): Instances.
          categorical_mask (Iterable[bool]): Boolean mask on which columns are categorical.
  
      Returns:
          List[Tuple[str, str, float, bool]]: Tuples of form: (name, description, value, is_lower_better).
      """
      data = X.values
  
      avg_prop_special_values = 0.0
      for index, _ in enumerate(X):
          prop_special_values = 0.0
          if categorical_mask[index]:
              for val in data[:, index]:
                  if pd.isnull(val) or val == " " or val == "":
                      prop_special_values += 1.0
          else:
              for val in data[:, index]:
                  if pd.isnull(val) or val == 0:
                      prop_special_values += 1.0
          prop_special_values /= X.shape[0]
          avg_prop_special_values += prop_special_values
      avg_prop_special_values /= X.shape[1]
  
      prop_cat_cols = float(sum([int(x) for x in categorical_mask]))
      prop_cat_cols /= len(categorical_mask)
  
      return [
          ("n_rows", "Number of rows.", float(X.shape[0]), False),
          ("n_cols", "Number of columns.", float(X.shape[1]), True),
          (
              "prop_cat_cols",
              "Proportion of categorical columns",
              float(prop_cat_cols),
              True,
          ),
          (
              "row_col_ratio",
              "Row to column ratio",
              float(X.shape[0] / X.shape[1]),
              True,
          ),
          (
              "avg_prop_special_values",
              "Average number of special value proportion per column.",
              float(avg_prop_special_values),
              True,
          ),
      ]
  
file_path: interpret/python/powerlift/src/powerlift/measures/task_measures.py
imports: from math import log, e
  from numbers import Number
  from typing import Iterable, List, Tuple
  import numpy
  import pandas
label_desc: Use image node_id 4 for calling a global function with example usage: data_stats(X, categorical_mask) and returns: list