How to use the pdpipe.basic_stages.RowDrop function in pdpipe

To help you get started, weโ€™ve selected a few pdpipe examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pdpipe / pdpipe / tests / basic_stages / test_row_drop.py View on Github external
def test_row_drop_xor_reducer():
    """Testing the ColDrop pipeline stage."""
    res_df = RowDrop([lambda x: x < 3]).apply(DF3)
    assert 1 not in res_df.index
    assert 2 not in res_df.index
    assert 3 in res_df.index

    res_df = RowDrop([lambda x: x < 3], reduce='xor').apply(DF3)
    assert 1 in res_df.index
    assert 2 not in res_df.index
    assert 3 in res_df.index
github pdpipe / pdpipe / tests / basic_stages / test_row_drop.py View on Github external
def test_row_drop_all_reducer():
    """Testing the ColDrop pipeline stage."""
    res_df = RowDrop([lambda x: x < 3]).apply(DF3)
    assert 1 not in res_df.index
    assert 2 not in res_df.index
    assert 3 in res_df.index

    res_df = RowDrop([lambda x: x < 3], reduce='all').apply(DF3)
    assert 1 not in res_df.index
    assert 2 in res_df.index
    assert 3 in res_df.index
github pdpipe / pdpipe / tests / basic_stages / test_row_drop.py View on Github external
def test_row_drop_bad_reducer():
    """Testing the ColDrop pipeline stage."""
    with pytest.raises(ValueError):
        RowDrop([lambda x: x < 2], reduce='al')
github pdpipe / pdpipe / tests / basic_stages / test_row_drop.py View on Github external
def test_row_drop_all_reducer():
    """Testing the ColDrop pipeline stage."""
    res_df = RowDrop([lambda x: x < 3]).apply(DF3)
    assert 1 not in res_df.index
    assert 2 not in res_df.index
    assert 3 in res_df.index

    res_df = RowDrop([lambda x: x < 3], reduce='all').apply(DF3)
    assert 1 not in res_df.index
    assert 2 in res_df.index
    assert 3 in res_df.index
github pdpipe / pdpipe / tests / basic_stages / test_row_drop.py View on Github external
def test_row_drop_columns():
    """Testing the ColDrop pipeline stage."""
    res_df = RowDrop([lambda x: x < 2]).apply(DF2)
    assert 1 not in res_df.index
    assert 2 not in res_df.index
    assert 3 in res_df.index

    res_df = RowDrop([lambda x: x < 2], columns=['a', 'b']).apply(DF2)
    assert 1 not in res_df.index
    assert 2 in res_df.index
    assert 3 in res_df.index
github pdpipe / pdpipe / tests / basic_stages / test_row_drop.py View on Github external
def test_row_drop_xor_reducer():
    """Testing the ColDrop pipeline stage."""
    res_df = RowDrop([lambda x: x < 3]).apply(DF3)
    assert 1 not in res_df.index
    assert 2 not in res_df.index
    assert 3 in res_df.index

    res_df = RowDrop([lambda x: x < 3], reduce='xor').apply(DF3)
    assert 1 in res_df.index
    assert 2 not in res_df.index
    assert 3 in res_df.index
github pdpipe / pdpipe / tests / basic_stages / test_row_drop.py View on Github external
def test_row_drop_verbose():
    """Testing the ColDrop pipeline stage."""
    res_df = RowDrop([lambda x: x < 2]).apply(DF1, verbose=True)
    assert 1 not in res_df.index
    assert 2 in res_df.index
    assert 3 in res_df.index
github pdpipe / pdpipe / tests / basic_stages / test_row_drop.py View on Github external
def test_row_droo_bad_columns():
    """Testing the ColDrop pipeline stage."""
    with pytest.raises(FailedPreconditionError):
        RowDrop([lambda x: x < 2], columns=['d']).apply(DF1)
github pdpipe / pdpipe / pdpipe / basic_stages.py View on Github external
self._columns_str = ""
        if self._cond_is_dict:
            valid = all([callable(cond) for cond in conditions.values()])
            if not valid:
                raise ValueError(
                    "Condition dicts given to RowDrop must map to callables!")
            self._columns = list(conditions.keys())
            self._columns_str = _list_str(self._columns)
        else:
            valid = all([callable(cond) for cond in conditions])
            if not valid:
                raise ValueError(
                    "RowDrop condition lists can contain only callables!")
        self._row_cond = self._row_condition_builder(conditions, reduce)
        super_kwargs = {
            'exmsg': RowDrop._DEF_ROWDROP_EXC_MSG.format(self._columns_str),
            'appmsg': RowDrop._DEF_ROWDROP_APPLY_MSG.format(self._columns_str),
            'desc': self._default_desc()
        }
        super_kwargs.update(**kwargs)
        super().__init__(**super_kwargs)
github pdpipe / pdpipe / pdpipe / basic_stages.py View on Github external
if self._cond_is_dict:
            valid = all([callable(cond) for cond in conditions.values()])
            if not valid:
                raise ValueError(
                    "Condition dicts given to RowDrop must map to callables!")
            self._columns = list(conditions.keys())
            self._columns_str = _list_str(self._columns)
        else:
            valid = all([callable(cond) for cond in conditions])
            if not valid:
                raise ValueError(
                    "RowDrop condition lists can contain only callables!")
        self._row_cond = self._row_condition_builder(conditions, reduce)
        super_kwargs = {
            'exmsg': RowDrop._DEF_ROWDROP_EXC_MSG.format(self._columns_str),
            'appmsg': RowDrop._DEF_ROWDROP_APPLY_MSG.format(self._columns_str),
            'desc': self._default_desc()
        }
        super_kwargs.update(**kwargs)
        super().__init__(**super_kwargs)