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

Fix pandas FutureWarning in UniformEncoder #819

Closed
R-Palazzo opened this issue May 9, 2024 · 0 comments · Fixed by #820
Closed

Fix pandas FutureWarning in UniformEncoder #819

R-Palazzo opened this issue May 9, 2024 · 0 comments · Fixed by #820
Assignees
Labels
bug Something isn't working
Milestone

Comments

@R-Palazzo
Copy link
Contributor

R-Palazzo commented May 9, 2024

Environment Details

  • RDT version: 1.12.1

Error Description

In the UniformEncoder, replacing NaN raises the following FutureWarning sometimes:

FutureWarning: The behavior of Series.replace (and DataFrame.replace) with CategoricalDtype is deprecated. 
In a future version, replace will only be used for cases that preserve the categories. 
To change the categories, use ser.cat.rename_categories instead.

It gets raised here:

result = result.replace(nan_name, np.nan)

A fix here would be to use ser.cat.remove_categories()

Step to reproduce

from rdt.transformers import UniformEncoder

intervals = {
    ' United-States': [0.0, 0.8], None: [0.8, 0.9],' Jamaica': [0.9, 0.99]
}
data = pd.Series([0.107995, 0.148025, 0.632702], name='native-country', dtype=float)
transformer = UniformEncoder()
transformer.intervals = intervals
transformer.dtype = 'O'
transformer._reverse_transform(data)
@R-Palazzo R-Palazzo added the bug Something isn't working label May 9, 2024
@gsheni gsheni changed the title Fix pandas FutureWarning in UnfiromEncoder Fix pandas FutureWarning in UniformEncoder May 9, 2024
@amontanez24 amontanez24 added this to the 1.12.1 milestone May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants