Skip to content

Conversation

@Astha0024
Copy link

removing infer because it changed manually converted object columns back to int or float

removing infer because it changed manually converted object columns back to int or float
@solegalli
Copy link
Collaborator

Hi @Astha0024 thanks for the PR.

I remember vaguely adding the infer recently due to some pandas upgrade or something, By removing it, other tests fail.

What's the issue that you are having? could you add an example?

@Astha0024
Copy link
Author

So sometimes a column that could be inferred at numerical needs to be cast to object type for example : number of bathrooms in a house. Then when we pass it through this transformation, the infer converts it back to int and then we can't run encoding on top of it.

@solegalli solegalli changed the title Update base_imputer.py [FIX] Update base_imputer.py Apr 26, 2025
@solegalli
Copy link
Collaborator

The CategoricalEncoder has the option to return numerical variables that were encoded as object both as object or as number after the imputation.

To return the variables as object, ensure you set the parameter return_object=True when setting up the transformer:

For example:

    imputer = CategoricalImputer(
        imputation_method="frequent",
        variables=["City", "Studies", "Marks"],
        return_object=True,
    )

@solegalli solegalli changed the title [FIX] Update base_imputer.py Update base_imputer.py Apr 26, 2025
@solegalli solegalli closed this Apr 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants