class_docstr: Class storing data for an experiment.
  
  The dataframe is retrieved via the `df` property. The data can be stored
  to an external store for future use by attaching it to an experiment using
  `experiment.attach_data()` (this requires a description to be set.)
  
  
  Attributes:
      df: DataFrame with underlying data, and required columns. For BaseData, the
          one required column is "arm_name".
      description: Human-readable description of data.
class_docstr_tok: ["Class","storing","data","for","an","experiment",".","The","dataframe","is","retrieved","via","the","`","df","`","property",".","The","data","can","be","stored","to","an","external","store","for","future","use","by","attaching","it","to","an","experiment","using","`","experiment.attach_data","(",")","`","(","this","requires","a","description","to","be","set",".",")","Attributes",":","df",":","DataFrame","with","underlying","data",",","and","required","columns",".","For","BaseData",",","the","one","required","column","is","``","arm_name","''",".","description",":","Human-readable","description","of","data","."]
docstr: Function for safely casting df to standard data types.
  
  Needed because numpy does not support NaNs in integer arrays.
  
  Allows `Any` to be specified as a type, and will skip casting for that column.
  
  Args:
      df: DataFrame to safe-cast.
      extra_column_types: types of columns only specified at instantiation-time.
  
  Returns:
      safe_df: DataFrame cast to standard dtypes.
docstr_tok: ["Function","for","safely","casting","df","to","standard","data","types",".","Needed","because","numpy","does","not","support","NaNs","in","integer","arrays",".","Allows","`","Any","`","to","be","specified","as","a","type",",","and","will","skip","casting","for","that","column",".","Args",":","df",":","DataFrame","to","safe-cast",".","extra_column_types",":","types","of","columns","only","specified","at","instantiation-time",".","Returns",":","safe_df",":","DataFrame","cast","to","standard","dtypes","."]
code: def _safecast_df(
      cls: Type[TBaseData],
      df: pd.DataFrame,
      # pyre-fixme[24]: Generic type `type` expects 1 type parameter, use
      #  `typing.Type` to avoid runtime subscripting errors.
      extra_column_types: Optional[Dict[str, Type]] = None,
  ) -> pd.DataFrame:
      """Function for safely casting df to standard data types.
  
      Needed because numpy does not support NaNs in integer arrays.
  
      Allows `Any` to be specified as a type, and will skip casting for that column.
  
      Args:
          df: DataFrame to safe-cast.
          extra_column_types: types of columns only specified at instantiation-time.
  
      Returns:
          safe_df: DataFrame cast to standard dtypes.
  
      """
      extra_column_types = extra_column_types or {}
      dtype = {
          # Pandas timestamp handlng is weird
          col: "datetime64[ns]" if coltype is pd.Timestamp else coltype
          for col, coltype in cls.column_data_types(
              extra_column_types=extra_column_types
          ).items()
          if col in df.columns.values
          and not (
              cls.column_data_types(extra_column_types)[col] is int
              and df.loc[:, col].isnull().any()
          )
          and not (coltype is Any)
      }
  
      return checked_cast(pd.DataFrame, df.astype(dtype=dtype))
  
imports: from __future__ import annotations
  import json
  from abc import abstractmethod
  from functools import reduce
  from hashlib import md5
  from typing import Any, Dict, Iterable, List, Optional, Set, Type, TypeVar, Union
  import numpy
  import pandas
  from ax.core.types import TFidelityTrialEvaluation, TTrialEvaluation
  from ax.utils.common.base import Base
  from ax.utils.common.serialization import extract_init_args, SerializationMixin, serialize_init_args, TClassDecoderRegistry, TDecoderRegistry
  from ax.utils.common.typeutils import checked_cast, not_none
label_desc: Use image node_id 2 for calling the BaseData obj's underlying member method code with example usage: obj._safecast_df(cls, df, extra_column_types) and returns: checked_cast