code: def _convert_to_dataset_class(df, dataset_class, expectations_config=None, autoinspect_func=None):
      
      if expectations_config is not None:
          # Cast the dataframe into the new class, and manually initialize expectations according to the provided configuration
          df.__class__ = dataset_class
          df._initialize_expectations(expectations_config)
      else:
          # Instantiate the new Dataset with default expectations
          try:
              df = dataset_class(df, autoinspect_func=autoinspect_func)
          except:
              raise NotImplementedError(
                  "read_csv requires a Dataset class that can be instantiated from a Pandas DataFrame")
  
      return df
docs: Convert a (pandas) dataframe to a great_expectations dataset, with (optional) expectations_config