Beispiel #1
0
def filter(table, predicates):
    """
    Select rows from table based on boolean expressions

    Parameters
    ----------
    predicates : boolean array expressions, or list thereof

    Returns
    -------
    filtered_expr : TableExpr
    """
    if isinstance(predicates, Expr):
        predicates = _L.unwrap_ands(predicates)
    predicates = util.promote_list(predicates)

    predicates = [ir.bind_expr(table, x) for x in predicates]

    resolved_predicates = []
    for pred in predicates:
        if isinstance(pred, ir.AnalyticExpr):
            pred = pred.to_filter()
        resolved_predicates.append(pred)

    op = _L.apply_filter(table, resolved_predicates)
    return TableExpr(op)
Beispiel #2
0
def filter(table, predicates):
    """
    Select rows from table based on boolean expressions

    Parameters
    ----------
    predicates : boolean array expressions, or list thereof

    Returns
    -------
    filtered_expr : TableExpr
    """
    if isinstance(predicates, Expr):
        predicates = _L.unwrap_ands(predicates)
    predicates = util.promote_list(predicates)

    predicates = [ir.bind_expr(table, x) for x in predicates]

    resolved_predicates = []
    for pred in predicates:
        if isinstance(pred, ir.AnalyticExpr):
            pred = pred.to_filter()
        resolved_predicates.append(pred)

    op = _L.apply_filter(table, resolved_predicates)
    return TableExpr(op)
Beispiel #3
0
    def filter(
        self,
        predicates: ir.BooleanValue | Sequence[ir.BooleanValue],
    ) -> Table:
        """Select rows from `table` based on `predicates`.

        Parameters
        ----------
        predicates
            Boolean value expressions used to select rows in `table`.

        Returns
        -------
        Table
            Filtered table expression
        """
        from ibis.expr import analysis as an

        resolved_predicates, top_ks = _resolve_predicates(self, predicates)
        child = self
        for predicate, right in top_ks:
            child = child.semi_join(right, predicate)[child]
        return an.apply_filter(
            child,
            [
                an._rewrite_filter(pred.op(), pred)
                for pred in resolved_predicates
            ],
        )
Beispiel #4
0
def filter(table, predicates):
    """
    Select rows from table based on boolean expressions

    Parameters
    ----------
    predicates : boolean array expressions, or list thereof

    Returns
    -------
    filtered_expr : TableExpr
    """
    resolved_predicates = _resolve_predicates(table, predicates)
    return _L.apply_filter(table, resolved_predicates)
Beispiel #5
0
def filter(table, predicates):
    """
    Select rows from table based on boolean expressions

    Parameters
    ----------
    predicates : boolean array expressions, or list thereof

    Returns
    -------
    filtered_expr : TableExpr
    """
    if isinstance(predicates, Expr):
        predicates = _L.unwrap_ands(predicates)

    op = _L.apply_filter(table, predicates)
    return TableExpr(op)
Beispiel #6
0
def filter(table, predicates):
    """
    Select rows from table based on boolean expressions

    Parameters
    ----------
    predicates : boolean array expressions, or list thereof

    Returns
    -------
    filtered_expr : TableExpr
    """
    if isinstance(predicates, Expr):
        predicates = _L.unwrap_ands(predicates)

    op = _L.apply_filter(table, predicates)
    return TableExpr(op)
Beispiel #7
0
    def filter(
        self,
        predicates: ir.BooleanValue | Sequence[ir.BooleanValue],
    ) -> TableExpr:
        """Select rows from `table` based on `predicates`.

        Parameters
        ----------
        predicates
            Boolean value expressions used to select rows in `table`.

        Returns
        -------
        TableExpr
            Filtered table expression
        """
        from .. import analysis as an

        resolved_predicates = _resolve_predicates(self, predicates)
        return an.apply_filter(self, resolved_predicates)