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 H2OFrame.isin #16043

Closed
tomasfryda opened this issue Jan 30, 2024 · 0 comments
Closed

Fix H2OFrame.isin #16043

tomasfryda opened this issue Jan 30, 2024 · 0 comments
Assignees
Labels
Milestone

Comments

@tomasfryda
Copy link
Contributor

This is similar to what was done in R's %in% in #15929

The goal is to enable subsetting via frame[(frame[column].isin(values)), :] as it was before the AstMatch behavior changed.

Test:

import os
import sys
sys.path.insert(1, os.path.join("..", "..", ".."))

import h2o
from tests import pyunit_utils


def test_isin_issue():
    frame = h2o.upload_file(pyunit_utils.locate("smalldata/titanic/titanic_expanded.csv"))
    column = "cabin"
    levels = frame[column].levels()[0][:-10]
    assert len(levels) > 10
    print(frame[column].isin(levels).unique())
    # expecting a binary vector as in pandas
    assert frame[column].isin(levels).unique().nrows == 2
    assert frame.as_data_frame(use_pandas=True)[column].isin(levels).nunique() == 2


pyunit_utils.run_tests([test_isin_issue])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants