code: def _cast_var_as_type(df, var, new_type):
      df_copy = df.copy()
      df_copy[var] = df[var].astype(new_type)
      return df_copy
  
file_path: feature_engine/tests/test_variable_handling/test_variable_type_selection.py
imports: import pandas
  import pytest
  from feature_engine._variable_handling.variable_type_selection import _filter_out_variables_not_in_dataframe, _find_all_variables, _find_categorical_and_numerical_variables, _find_or_check_categorical_variables, _find_or_check_datetime_variables, _find_or_check_numerical_variables
label_desc: Use image node_id 2 for calling a global function with example usage: _cast_var_as_type(df, var, new_type) and returns: df_copy