def _validate_dataframe(self, df: pd.DataFrame) -> List[str]:
    """Returns a list of type mismatches if any are found, or raises an error."""
    assert isinstance(df, pd.DataFrame), f"unexpected type: {type(df)}"
    lines = []
    # Check index types
    if type(df.index) == pd.MultiIndex:
      for name, dtype in df.index.dtypes.to_dict().items():
        lines.extend(self._check_name_and_type(name, dtype))
    elif type(df.index) == pd.RangeIndex or df.index.name is None:
      # Index is uninteresting - none was specified by the caller.
      pass
    else:
      lines.extend(self._check_name_and_type(df.index.name, df.index.dtype))
    # Check column types
    for name, dtype in df.dtypes.to_dict().items():
      lines.extend(self._check_name_and_type(name, dtype))
    return lines
Returns a list of type mismatches if any are found, or raises an error.
sourcecode/scoring/pandas_utils.py