<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _maybe_from_pandas(data, feature_names, feature_types):
 """ Extract internal data from pd.DataFrame """

    try:
        import pandas as pd
    except ImportError:
        return data, feature_names, feature_types

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

    dtypes = data.dtypes
    if not all(dtype.name in ('int64', 'float64', 'bool') for dtype in dtypes):
        raise ValueError('DataFrame.dtypes must be int, float or bool')

    if feature_names is None:
        feature_names = data.columns.format()
    if feature_types is None:
        mapper = {'int64': 'int', 'float64': 'q', 'bool': 'i'}
        feature_types = [mapper[dtype.name] for dtype in dtypes]
    data = data.values.astype('float')
    return data, feature_names, feature_types