Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove fillna call in ArbitraryImputer (Issue 195) #198

Merged
merged 4 commits into from
Mar 18, 2024

Conversation

Ritunjai-Sharma
Copy link
Contributor

ArbitraryImputer was calling fillna both in it's own transform method, and in the BaseImputer method.

To increase tubular's efficiency and maintainability, have removed fillna call in ArbitraryImputer and moved the logic for "casting imputer value as same dtype as original column" below the BaseImputer.transform call.

Note that the above change caused the test_impute_values_set in test_ArbitraryImputer.py to fail since the initial mock setup for BaseImputer.transform was returning a simple integer:1234. However, this causes 'TypeError: 'int' object is not superscriptable' for the following code line in transform method of ArbitraryImputer: X_transformed[c] = X_transformed[c].astype(dtype), since an integer cannot be treated as a collection. Therefore have updated test_impute_values_set to mock BaseImputer.transform to return a dataframe rather than an int

@Ritunjai-Sharma Ritunjai-Sharma linked an issue Mar 14, 2024 that may be closed by this pull request
@Ritunjai-Sharma Ritunjai-Sharma marked this pull request as ready for review March 14, 2024 13:33
@limlam96
Copy link
Contributor

This looks good to me RJ, looks like there are just a couple of ruff things failing in CI - could you fix those and then will approve? :)

@Ritunjai-Sharma
Copy link
Contributor Author

Hi Liam, the ruff linting errors seem to be from tests/imputers/test_BaseImputer.py due to using np.NaN rather than np.nan. I have made this replacement now and all the checks are passing :)

Copy link
Contributor

@limlam96 limlam96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks RJ - approved!

Copy link
Contributor

@limlam96 limlam96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually just realised, can you please update the changelog :)

@Ritunjai-Sharma
Copy link
Contributor Author

Done! Have a look at the changelog and let me know if it's fine :)

Copy link
Contributor

@limlam96 limlam96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great thank you - approved again :)

@Ritunjai-Sharma Ritunjai-Sharma merged commit ec43ed4 into main Mar 18, 2024
12 checks passed
@Ritunjai-Sharma Ritunjai-Sharma deleted the 195-arbitrary-imputer-calls-fillna-twice branch March 18, 2024 16:04
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.

Arbitrary Imputer calls fillna twice
2 participants