parameters: (data, copy: bool)
return_statement: return data, copy
docstring: 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
docstring_summary: Convert data based on dtype conventions, issuing deprecation warnings
      or errors where appropriate.
docstring_tokens: Convert data based on dtype conventions issuing deprecation warnings or errors where appropriate .
function: def maybe_convert_dtype(data, copy: bool):
      """
      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
      """
      if not hasattr(data, "dtype"):
          # e.g. collections.deque
          return data, copy
  
      if is_float_dtype(data.dtype):
          # Note: we must cast to datetime64[ns] here in order to treat these
          #  as wall-times instead of UTC timestamps.
          data = data.astype(DT64NS_DTYPE)
          copy = False
          # TODO: deprecate this behavior to instead treat symmetrically
          #  with integer dtypes.  See discussion in GH#23675
  
      elif is_timedelta64_dtype(data.dtype) or is_bool_dtype(data.dtype):
          # GH#29794 enforcing deprecation introduced in GH#23539
          raise TypeError(f"dtype {data.dtype} cannot be converted to datetime64[ns]")
      elif is_period_dtype(data.dtype):
          # Note: without explicitly raising here, PeriodIndex
          #  test_setops.test_join_does_not_recur fails
          raise TypeError(
              "Passing PeriodDtype data is invalid. Use `data.to_timestamp()` instead"
          )
  
      elif is_categorical_dtype(data.dtype):
          # GH#18664 preserve tz in going DTI->Categorical->DTI
          # TODO: cases where we need to do another pass through this func,
          #  e.g. the categories are timedelta64s
          data = data.categories.take(data.codes, fill_value=NaT)._values
          copy = False
  
      elif is_extension_array_dtype(data.dtype) and not is_datetime64tz_dtype(data.dtype):
          # Includes categorical
          # TODO: We have no tests for these
          data = np.array(data, dtype=np.object_)
          copy = False
  
      return data, copy
function_tokens: def maybe_convert_dtype ( data , copy : bool ) : if not hasattr ( data , "dtype" ) : # e.g. collections.deque return data , copy if is_float_dtype ( data . dtype ) : # Note: we must cast to datetime64[ns] here in order to treat these #  as wall-times instead of UTC timestamps. data = data . astype ( DT64NS_DTYPE ) copy = False # TODO: deprecate this behavior to instead treat symmetrically #  with integer dtypes.  See discussion in GH#23675 elif is_timedelta64_dtype ( data . dtype ) or is_bool_dtype ( data . dtype ) : # GH#29794 enforcing deprecation introduced in GH#23539 raise TypeError ( f"dtype {data.dtype} cannot be converted to datetime64[ns]" ) elif is_period_dtype ( data . dtype ) : # Note: without explicitly raising here, PeriodIndex #  test_setops.test_join_does_not_recur fails raise TypeError ( "Passing PeriodDtype data is invalid. Use `data.to_timestamp()` instead" ) elif is_categorical_dtype ( data . dtype ) : # GH#18664 preserve tz in going DTI->Categorical->DTI # TODO: cases where we need to do another pass through this func, #  e.g. the categories are timedelta64s data = data . categories . take ( data . codes , fill_value = NaT ) . _values copy = False elif is_extension_array_dtype ( data . dtype ) and not is_datetime64tz_dtype ( data . dtype ) : # Includes categorical # TODO: We have no tests for these data = np . array ( data , dtype = np . object_ ) copy = False return data , copy