Example #1
0
def topk(arg, k, by=None):
    """
    Produces

    Returns
    -------
    topk : TopK filter expression
    """
    op = _ops.TopK(arg, k, by=by)
    return op.to_expr()
Example #2
0
    def topk(
        self,
        k: int,
        by: ir.Value | None = None,
    ) -> ir.TopK:
        """Return a "top k" expression.

        Parameters
        ----------
        k
            Return this number of rows
        by
            An expression. Defaults to the count

        Returns
        -------
        TopK
            A top-k expression
        """
        import ibis.expr.operations as ops

        op = ops.TopK(self, k, by=by if by is not None else self.count())
        return op.to_expr()