code: def test_imputation_of_numerical_vars_cast_as_object_and_returned_as_numerical(
      df_na,
  ):
      # test case: imputing of numerical variables cast as object + return numeric
      df_na = df_na.copy()
      df_na["Marks"] = df_na["Marks"].astype("O")
      imputer = CategoricalImputer(
          imputation_method="frequent",
          variables=["City", "Studies", "Marks"],
      )
      X_transformed = imputer.fit_transform(df_na)
  
      X_reference = df_na.copy()
      X_reference["Marks"] = X_reference["Marks"].fillna(0.8)
      X_reference["City"] = X_reference["City"].fillna("London")
      X_reference["Studies"] = X_reference["Studies"].fillna("Bachelor")
      assert imputer.variables == ["City", "Studies", "Marks"]
      assert imputer.variables_ == ["City", "Studies", "Marks"]
      assert imputer.imputer_dict_ == {
          "Studies": "Bachelor",
          "City": "London",
          "Marks": 0.8,
      }
      assert X_transformed["Marks"].dtype == "float"
      pd.testing.assert_frame_equal(X_transformed, X_reference)
  
file_path: feature_engine/tests/test_imputation/test_categorical_imputer.py
imports: import pandas
  import pytest
  from feature_engine.imputation import CategoricalImputer
label_desc: Use image node_id 5 for calling a global function with example usage: test_imputation_of_numerical_vars_cast_as_object_and_returned_as_numerical(df_na) without return types