def _maybe_pandas_data(data, feature_names, feature_types):
    """ Extract internal data from pd.DataFrame for DMatrix data """

    if not isinstance(data, DataFrame):
        return data, feature_names, feature_types

    data_dtypes = data.dtypes
    if not all(dtype.name in PANDAS_DTYPE_MAPPER for dtype in data_dtypes):
        bad_fields = [data.columns[i] for i, dtype in
                      enumerate(data_dtypes) if dtype.name not in PANDAS_DTYPE_MAPPER]

        msg = """DataFrame.dtypes for data must be int, float or bool.
                Did not expect the data types in fields """
        raise ValueError(msg + ', '.join(bad_fields))

    if feature_names is None:
        if isinstance(data.columns, MultiIndex):
            feature_names = [
                ' '.join([str(x) for x in i])
                for i in data.columns
            ]
        else:
            feature_names = data.columns.format()

    if feature_types is None:
        feature_types = [PANDAS_DTYPE_MAPPER[dtype.name] for dtype in data_dtypes]

    data = data.values.astype('float')

    return data, feature_names, feature_types
def _maybe_pandas_data ( data , feature_names , feature_types ) : if not isinstance ( data , DataFrame ) : return data , feature_names , feature_types data_dtypes = data . dtypes if not all ( dtype . name in PANDAS_DTYPE_MAPPER for dtype in data_dtypes ) : bad_fields = [ data . columns [ i ] for i , dtype in enumerate ( data_dtypes ) if dtype . name not in PANDAS_DTYPE_MAPPER ] msg = """DataFrame.dtypes for data must be int, float or bool.
                Did not expect the data types in fields """ raise ValueError ( msg + ', ' . join ( bad_fields ) ) if feature_names is None : if isinstance ( data . columns , MultiIndex ) : feature_names = [ ' ' . join ( [ str ( x ) for x in i ] ) for i in data . columns ] else : feature_names = data . columns . format ( ) if feature_types is None : feature_types = [ PANDAS_DTYPE_MAPPER [ dtype . name ] for dtype in data_dtypes ] data = data . values . astype ( 'float' ) return data , feature_names , feature_types
Extract internal data from pd.DataFrame for DMatrix data