Skip to content

Commit

Permalink
docs(examples): add IntegerColumn bitwise aggregegate examples
Browse files Browse the repository at this point in the history
  • Loading branch information
IndexSeek authored and cpcloud committed Oct 31, 2024
1 parent 964be8c commit a189c5a
Showing 1 changed file with 48 additions and 3 deletions.
51 changes: 48 additions & 3 deletions ibis/expr/types/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -1231,15 +1231,60 @@ class IntegerScalar(NumericScalar, IntegerValue):
@public
class IntegerColumn(NumericColumn, IntegerValue):
def bit_and(self, where: ir.BooleanValue | None = None) -> IntegerScalar:
"""Aggregate the column using the bitwise and operator."""
"""Aggregate the column using the bitwise and operator.
Examples
--------
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"x": [-1, 0, 1]})
>>> t.x.bit_and()
┌───┐
│ 0 │
└───┘
>>> t.x.bit_and(where=t.x != 0)
┌───┐
│ 1 │
└───┘
"""
return ops.BitAnd(self, where=self._bind_to_parent_table(where)).to_expr()

def bit_or(self, where: ir.BooleanValue | None = None) -> IntegerScalar:
"""Aggregate the column using the bitwise or operator."""
"""Aggregate the column using the bitwise or operator.
Examples
--------
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"x": [-1, 0, 1]})
>>> t.x.bit_or()
┌────┐
│ -1 │
└────┘
>>> t.x.bit_or(where=t.x >= 0)
┌───┐
│ 1 │
└───┘
"""
return ops.BitOr(self, where=self._bind_to_parent_table(where)).to_expr()

def bit_xor(self, where: ir.BooleanValue | None = None) -> IntegerScalar:
"""Aggregate the column using the bitwise exclusive or operator."""
"""Aggregate the column using the bitwise exclusive or operator.
Examples
--------
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"x": [-1, 0, 1]})
>>> t.x.bit_xor()
┌────┐
│ -2 │
└────┘
>>> t.x.bit_xor(where=t.x >= 0)
┌───┐
│ 1 │
└───┘
"""
return ops.BitXor(self, where=self._bind_to_parent_table(where)).to_expr()


Expand Down

0 comments on commit a189c5a

Please sign in to comment.