def maybe_convert_dtype(data, copy):
if is_float_dtype(data):<EOL><INDENT>data = data.astype(_NS_DTYPE)<EOL>copy = False<EOL><DEDENT>elif is_timedelta64_dtype(data):<EOL><INDENT>warnings.warn("<STR_LIT>"<EOL>"<STR_LIT>",<EOL>FutureWarning, stacklevel=<NUM_LIT:5>)<EOL>data = data.view(_NS_DTYPE)<EOL><DEDENT>elif is_period_dtype(data):<EOL><INDENT>raise TypeError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>elif is_categorical_dtype(data):<EOL><INDENT>data = data.categories.take(data.codes, fill_value=NaT)._values<EOL>copy = False<EOL><DEDENT>elif is_extension_type(data) and not is_datetime64tz_dtype(data):<EOL><INDENT>data = np.array(data, dtype=np.object_)<EOL>copy = False<EOL><DEDENT>return data, copy<EOL>
Convert data based on dtype conventions, issuing deprecation warnings
or errors where appropriate.

Parameters
----------
data : np.ndarray or pd.Index
copy : bool

Returns
-------
data : np.ndarray or pd.Index
copy : bool

Raises
------
TypeError : PeriodDType data is passed