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

[data/preprocessors] do not fail transform_batch on missing column #48137

Merged

Conversation

martinbomio
Copy link
Contributor

@martinbomio martinbomio commented Oct 21, 2024

Why are these changes needed?

Related issue number

Closes #48047

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

@@ -113,6 +125,8 @@ def test_simple_imputer():

assert constant_out_df.equals(constant_expected_df)

#
Copy link
Contributor

Choose a reason for hiding this comment

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

cleanup?

@@ -131,7 +131,14 @@ def _transform_pandas(self, df: pd.DataFrame):
if is_categorical_dtype(df.dtypes[column]):
df[column] = df[column].cat.add_categories(value)

df = df.fillna(new_values)
for column_name in new_values:
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add this behavior to the docstring as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

@martinbomio martinbomio force-pushed the martinbomio/imputer-missing-column branch 2 times, most recently from cb46a3d to 29a1ffc Compare October 22, 2024 01:32
@@ -13,7 +13,8 @@

@PublicAPI(stability="alpha")
class SimpleImputer(Preprocessor):
"""Replace missing values with imputed values.
"""Replace missing values with imputed values. If the column is missing from a
batch, it will be filled with the imputed valuegit.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: valuegit to value

Signed-off-by: Martin Bomio <martinbomio@gmail.com>
@martinbomio martinbomio force-pushed the martinbomio/imputer-missing-column branch from 29a1ffc to ef5d192 Compare October 23, 2024 01:41
@martinbomio
Copy link
Contributor Author

@omatthew98 @richardliaw would you mind merging, I can't

@richardliaw richardliaw changed the title fix: do not fail transform_batch on missing column [data/preprocessors] do not fail transform_batch on missing column Oct 23, 2024
@richardliaw richardliaw enabled auto-merge (squash) October 23, 2024 19:46
@github-actions github-actions bot added the go add ONLY when ready to merge, run all tests label Oct 23, 2024
@github-actions github-actions bot disabled auto-merge October 23, 2024 22:46
@richardliaw richardliaw merged commit 2d8bd9e into ray-project:master Oct 24, 2024
5 checks passed
JP-sDEV pushed a commit to JP-sDEV/ray that referenced this pull request Nov 14, 2024
mohitjain2504 pushed a commit to mohitjain2504/ray that referenced this pull request Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go add ONLY when ready to merge, run all tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Data]: SimpleImputer fails on transform_batch when column is completely missing from dataframe
3 participants