Numeric and Boolean Expressions¶
These APIs are available on numeric and boolean expressions.
NumericValue
¶
Bases: Value
Functions¶
__add__(other)
¶
Add self
with other
.
__floordiv__(other)
¶
Floor divide self
by other
.
__mod__(other)
¶
Compute self
modulo other
.
__mul__(other)
¶
Multiply self
and other
.
__neg__()
¶
__pow__(other)
¶
Raise self
to the other
th power.
__rfloordiv__(other)
¶
Floor divide other
by self
.
__rmod__(other)
¶
Compute other
modulo self
.
__rpow__(other)
¶
Raise other
to the self
th power.
__rsub__(other)
¶
Substract self
from other
.
__rtruediv__(other)
¶
Divide other
by self
.
__sub__(other)
¶
Substract other
from self
.
__truediv__(other)
¶
Divide self
by other
.
abs()
¶
Return the absolute value of self
.
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"values": [-1, 2, -3, 4]})
>>> t.values.abs()
┏━━━━━━━━━━━━━┓
┃ Abs(values) ┃
┡━━━━━━━━━━━━━┩
│ int64 │
├─────────────┤
│ 1 │
│ 2 │
│ 3 │
│ 4 │
└─────────────┘
acos()
¶
Compute the arc cosine of self
.
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"values": [-1, 0, 1]})
>>> t.values.acos()
┏━━━━━━━━━━━━━━┓
┃ Acos(values) ┃
┡━━━━━━━━━━━━━━┩
│ float64 │
├──────────────┤
│ 3.141593 │
│ 1.570796 │
│ 0.000000 │
└──────────────┘
asin()
¶
Compute the arc sine of self
.
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"values": [-1, 0, 1]})
>>> t.values.asin()
┏━━━━━━━━━━━━━━┓
┃ Asin(values) ┃
┡━━━━━━━━━━━━━━┩
│ float64 │
├──────────────┤
│ -1.570796 │
│ 0.000000 │
│ 1.570796 │
└──────────────┘
atan()
¶
Compute the arc tangent of self
.
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"values": [-1, 0, 1]})
>>> t.values.atan()
┏━━━━━━━━━━━━━━┓
┃ Atan(values) ┃
┡━━━━━━━━━━━━━━┩
│ float64 │
├──────────────┤
│ -0.785398 │
│ 0.000000 │
│ 0.785398 │
└──────────────┘
atan2(other)
¶
Compute the two-argument version of arc tangent.
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"values": [-1, 0, 1]})
>>> t.values.atan2(0)
┏━━━━━━━━━━━━━━━━━━┓
┃ Atan2(values, 0) ┃
┡━━━━━━━━━━━━━━━━━━┩
│ float64 │
├──────────────────┤
│ -1.570796 │
│ 0.000000 │
│ 1.570796 │
└──────────────────┘
ceil()
¶
Return the ceiling of self
.
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"values": [1, 1.1, 2, 2.1, 3.3]})
>>> t.values.ceil()
┏━━━━━━━━━━━━━━┓
┃ Ceil(values) ┃
┡━━━━━━━━━━━━━━┩
│ int64 │
├──────────────┤
│ 1 │
│ 2 │
│ 2 │
│ 3 │
│ 4 │
└──────────────┘
clip(lower=None, upper=None)
¶
Trim values outside of lower
and upper
bounds.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lower |
NumericValue | None
|
Lower bound |
None
|
upper |
NumericValue | None
|
Upper bound |
None
|
Returns:
Type | Description |
---|---|
NumericValue
|
Clipped input |
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"values": range(8)})
>>> t.values.clip(lower=3, upper=6)
┏━━━━━━━━━━━━━━━━━━━━┓
┃ Clip(values, 3, 6) ┃
┡━━━━━━━━━━━━━━━━━━━━┩
│ int64 │
├────────────────────┤
│ 3 │
│ 3 │
│ 3 │
│ 3 │
│ 4 │
│ 5 │
│ 6 │
│ 6 │
└────────────────────┘
cos()
¶
Compute the cosine of self
.
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"values": [-1, 0, 1]})
>>> t.values.cos()
┏━━━━━━━━━━━━━┓
┃ Cos(values) ┃
┡━━━━━━━━━━━━━┩
│ float64 │
├─────────────┤
│ 0.540302 │
│ 1.000000 │
│ 0.540302 │
└─────────────┘
cot()
¶
Compute the cotangent of self
.
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"values": [-1, 0, 1]})
>>> t.values.cot()
┏━━━━━━━━━━━━━┓
┃ Cot(values) ┃
┡━━━━━━━━━━━━━┩
│ float64 │
├─────────────┤
│ -0.642093 │
│ inf │
│ 0.642093 │
└─────────────┘
degrees()
¶
Compute the degrees of self
radians.
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> from math import pi
>>> t = ibis.memtable({"values": [0, pi / 2, pi, 3 * pi / 2, 2 * pi]})
>>> t.values.degrees()
┏━━━━━━━━━━━━━━━━━┓
┃ Degrees(values) ┃
┡━━━━━━━━━━━━━━━━━┩
│ float64 │
├─────────────────┤
│ 0.0 │
│ 90.0 │
│ 180.0 │
│ 270.0 │
│ 360.0 │
└─────────────────┘
exp()
¶
Compute \(e^\texttt{self}\).
Returns:
Type | Description |
---|---|
NumericValue
|
\(e^\texttt{self}\) |
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"values": range(4)})
>>> t.values.exp()
┏━━━━━━━━━━━━━┓
┃ Exp(values) ┃
┡━━━━━━━━━━━━━┩
│ float64 │
├─────────────┤
│ 1.000000 │
│ 2.718282 │
│ 7.389056 │
│ 20.085537 │
└─────────────┘
floor()
¶
Return the floor of an expression.
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"values": [1, 1.1, 2, 2.1, 3.3]})
>>> t.values.floor()
┏━━━━━━━━━━━━━━━┓
┃ Floor(values) ┃
┡━━━━━━━━━━━━━━━┩
│ int64 │
├───────────────┤
│ 1 │
│ 1 │
│ 2 │
│ 2 │
│ 3 │
└───────────────┘
ln()
¶
Compute \(\ln\left(\texttt{self}\right)\).
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"values": [1, 2.718281828, 3]})
>>> t.values.ln()
┏━━━━━━━━━━━━┓
┃ Ln(values) ┃
┡━━━━━━━━━━━━┩
│ float64 │
├────────────┤
│ 0.000000 │
│ 1.000000 │
│ 1.098612 │
└────────────┘
log(base=None)
¶
Return the logarithm using a specified base.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base |
NumericValue | None
|
The base of the logarithm. If |
None
|
Returns:
Type | Description |
---|---|
NumericValue
|
Logarithm of |
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> from math import e
>>> t = ibis.memtable({"values": [e, e**2, e**3]})
>>> t.values.log()
┏━━━━━━━━━━━━━┓
┃ Log(values) ┃
┡━━━━━━━━━━━━━┩
│ float64 │
├─────────────┤
│ 1.0 │
│ 2.0 │
│ 3.0 │
└─────────────┘
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"values": [10, 100, 1000]})
>>> t.values.log(base=10)
┏━━━━━━━━━━━━━━━━━┓
┃ Log(values, 10) ┃
┡━━━━━━━━━━━━━━━━━┩
│ float64 │
├─────────────────┤
│ 1.0 │
│ 2.0 │
│ 3.0 │
└─────────────────┘
log10()
¶
Compute \(\log_{10}\left(\texttt{self}\right)\).
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"values": [1, 10, 100]})
>>> t.values.log10()
┏━━━━━━━━━━━━━━━┓
┃ Log10(values) ┃
┡━━━━━━━━━━━━━━━┩
│ float64 │
├───────────────┤
│ 0.0 │
│ 1.0 │
│ 2.0 │
└───────────────┘
log2()
¶
Compute \(\log_{2}\left(\texttt{self}\right)\).
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"values": [1, 2, 4, 8]})
>>> t.values.log2()
┏━━━━━━━━━━━━━━┓
┃ Log2(values) ┃
┡━━━━━━━━━━━━━━┩
│ float64 │
├──────────────┤
│ 0.0 │
│ 1.0 │
│ 2.0 │
│ 3.0 │
└──────────────┘
negate()
¶
Negate a numeric expression.
Returns:
Type | Description |
---|---|
NumericValue
|
A numeric value expression |
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"values": [-1, 0, 1]})
>>> t.values.negate()
┏━━━━━━━━━━━━━━━━┓
┃ Negate(values) ┃
┡━━━━━━━━━━━━━━━━┩
│ int64 │
├────────────────┤
│ 1 │
│ 0 │
│ -1 │
└────────────────┘
nullifzero()
¶
Return NULL
if an expression is zero.
point(right)
¶
Return a point constructed from the coordinate values.
Constant coordinates result in construction of a POINT
literal or
column.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
right |
int | float | NumericValue
|
Y coordinate |
required |
Returns:
Type | Description |
---|---|
PointValue
|
Points |
radians()
¶
Compute radians from self
degrees.
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"values": [0, 90, 180, 270, 360]})
>>> t.values.radians()
┏━━━━━━━━━━━━━━━━━┓
┃ Radians(values) ┃
┡━━━━━━━━━━━━━━━━━┩
│ float64 │
├─────────────────┤
│ 0.000000 │
│ 1.570796 │
│ 3.141593 │
│ 4.712389 │
│ 6.283185 │
└─────────────────┘
round(digits=None)
¶
Round values to an indicated number of decimal places.
Parameters:
Name | Type | Description | Default | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
digits |
int | IntegerValue | None
|
The number of digits to round to. Here's how the
|
None
|
Returns:
Type | Description |
---|---|
NumericValue
|
The rounded expression |
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"values": [1.22, 1.64, 2.15, 2.54]})
>>> t
┏━━━━━━━━━┓
┃ values ┃
┡━━━━━━━━━┩
│ float64 │
├─────────┤
│ 1.22 │
│ 1.64 │
│ 2.15 │
│ 2.54 │
└─────────┘
>>> t.values.round()
┏━━━━━━━━━━━━━━━┓
┃ Round(values) ┃
┡━━━━━━━━━━━━━━━┩
│ int64 │
├───────────────┤
│ 1 │
│ 2 │
│ 2 │
│ 3 │
└───────────────┘
>>> t.values.round(digits=1)
┏━━━━━━━━━━━━━━━━━━┓
┃ Round(values, 1) ┃
┡━━━━━━━━━━━━━━━━━━┩
│ float64 │
├──────────────────┤
│ 1.2 │
│ 1.6 │
│ 2.2 │
│ 2.5 │
└──────────────────┘
sign()
¶
Return the sign of the input.
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"values": [-1, 2, -3, 4]})
>>> t.values.sign()
┏━━━━━━━━━━━━━━┓
┃ Sign(values) ┃
┡━━━━━━━━━━━━━━┩
│ int64 │
├──────────────┤
│ -1 │
│ 1 │
│ -1 │
│ 1 │
└──────────────┘
sin()
¶
Compute the sine of self
.
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"values": [-1, 0, 1]})
>>> t.values.sin()
┏━━━━━━━━━━━━━┓
┃ Sin(values) ┃
┡━━━━━━━━━━━━━┩
│ float64 │
├─────────────┤
│ -0.841471 │
│ 0.000000 │
│ 0.841471 │
└─────────────┘
sqrt()
¶
Compute the square root of self
.
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"values": [1, 4, 9, 16]})
>>> t.values.sqrt()
┏━━━━━━━━━━━━━━┓
┃ Sqrt(values) ┃
┡━━━━━━━━━━━━━━┩
│ float64 │
├──────────────┤
│ 1.0 │
│ 2.0 │
│ 3.0 │
│ 4.0 │
└──────────────┘
tan()
¶
Compute the tangent of self
.
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"values": [-1, 0, 1]})
>>> t.values.tan()
┏━━━━━━━━━━━━━┓
┃ Tan(values) ┃
┡━━━━━━━━━━━━━┩
│ float64 │
├─────────────┤
│ -1.557408 │
│ 0.000000 │
│ 1.557408 │
└─────────────┘
zeroifnull()
¶
Return zero if an expression is NULL
.
NumericColumn
¶
Bases: Column
, NumericValue
Functions¶
bucket(buckets, closed='left', close_extreme=True, include_under=False, include_over=False)
¶
Compute a discrete binning of a numeric array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buckets |
Sequence[int]
|
List of buckets |
required |
closed |
Literal['left', 'right']
|
Which side of each interval is closed. For example:
|
'left'
|
close_extreme |
bool
|
Whether the extreme values fall in the last bucket |
True
|
include_over |
bool
|
Include values greater than the last bucket in the last bucket |
False
|
include_under |
bool
|
Include values less than the first bucket in the first bucket |
False
|
Returns:
Type | Description |
---|---|
IntegerColumn
|
A categorical column expression |
corr(right, where=None, how='sample')
¶
Return the correlation of two numeric columns.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
right |
NumericColumn
|
Numeric column |
required |
where |
ir.BooleanValue | None
|
Filter |
None
|
how |
Literal['sample', 'pop']
|
Population or sample correlation |
'sample'
|
Returns:
Type | Description |
---|---|
NumericScalar
|
The correlation of |
cov(right, where=None, how='sample')
¶
Return the covariance of two numeric columns.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
right |
NumericColumn
|
Numeric column |
required |
where |
ir.BooleanValue | None
|
Filter |
None
|
how |
Literal['sample', 'pop']
|
Population or sample covariance |
'sample'
|
Returns:
Type | Description |
---|---|
NumericScalar
|
The covariance of |
cummean()
¶
Return the cumulative mean of the input.
cumsum()
¶
Return the cumulative sum of the input.
histogram(nbins=None, binwidth=None, base=None, eps=1e-13)
¶
Compute a histogram with fixed width bins.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nbins |
int | None
|
If supplied, will be used to compute the binwidth |
None
|
binwidth |
float | None
|
If not supplied, computed from the data (actual max and min values) |
None
|
base |
float | None
|
The value of the first histogram bin. Defaults to the minimum value
of |
None
|
eps |
float
|
Allowed floating point epsilon for histogram base |
1e-13
|
Returns:
Type | Description |
---|---|
Column
|
Bucketed column |
mean(where=None)
¶
Return the mean of a numeric column.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
where |
ir.BooleanValue | None
|
Filter |
None
|
Returns:
Type | Description |
---|---|
NumericScalar
|
The mean of the input expression |
median(where=None)
¶
Return the median of the column.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
where |
ir.BooleanValue | None
|
Optional boolean expression. If given, only the values where
|
None
|
Returns:
Type | Description |
---|---|
NumericScalar
|
Median of the column |
quantile(quantile, interpolation=None, where=None)
¶
Return value at the given quantile.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
quantile |
Sequence[NumericValue | float]
|
|
required |
interpolation |
Literal['linear', 'lower', 'higher', 'midpoint', 'nearest'] | None
|
This parameter is backend dependent and may have no effect This parameter specifies the interpolation method to use, when the
desired quantile lies between two data points
|
None
|
where |
ir.BooleanValue | None
|
Boolean filter for input values |
None
|
Returns:
Type | Description |
---|---|
NumericScalar
|
Quantile of the input |
std(where=None, how='sample')
¶
Return the standard deviation of a numeric column.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
where |
ir.BooleanValue | None
|
Filter |
None
|
how |
Literal['sample', 'pop']
|
Sample or population standard deviation |
'sample'
|
Returns:
Type | Description |
---|---|
NumericScalar
|
Standard deviation of |
sum(where=None)
¶
Return the sum of a numeric column.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
where |
ir.BooleanValue | None
|
Filter |
None
|
Returns:
Type | Description |
---|---|
NumericScalar
|
The sum of the input expression |
var(where=None, how='sample')
¶
Return the variance of a numeric column.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
where |
ir.BooleanValue | None
|
Filter |
None
|
how |
Literal['sample', 'pop']
|
Sample or population variance |
'sample'
|
Returns:
Type | Description |
---|---|
NumericScalar
|
Standard deviation of |
IntegerValue
¶
Bases: NumericValue
Functions¶
__and__(other)
¶
Bitwise and self
with other
.
__invert__()
¶
__lshift__(other)
¶
Bitwise left shift self
with other
.
__or__(other)
¶
Bitwise or self
with other
.
__rlshift__(other)
¶
Bitwise left shift self
with other
.
__rrshift__(other)
¶
Bitwise right shift self
with other
.
__rshift__(other)
¶
Bitwise right shift self
with other
.
__xor__(other)
¶
Bitwise xor self
with other
.
convert_base(from_base, to_base)
¶
Convert an integer from one base to another.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
from_base |
IntegerValue
|
Numeric base of expression |
required |
to_base |
IntegerValue
|
New base |
required |
Returns:
Type | Description |
---|---|
IntegerValue
|
Converted expression |
label(labels, nulls=None)
¶
Label a set of integer values with strings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
labels |
Iterable[str]
|
An iterable of string labels. Each integer value in |
required |
nulls |
str | None
|
String label to use for |
None
|
Returns:
Type | Description |
---|---|
StringValue
|
|
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"a": [0, 1, 0, 2]})
>>> t.select(t.a, labeled=t.a.label(["a", "b", "c"]))
┏━━━━━━━┳━━━━━━━━━┓
┃ a ┃ labeled ┃
┡━━━━━━━╇━━━━━━━━━┩
│ int64 │ string │
├───────┼─────────┤
│ 0 │ a │
│ 1 │ b │
│ 0 │ a │
│ 2 │ c │
└───────┴─────────┘
to_interval(unit='s')
¶
Convert an integer to an interval.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
unit |
Literal['Y', 'M', 'W', 'D', 'h', 'm', 's', 'ms', 'us', 'ns']
|
Unit for the resulting interval |
's'
|
Returns:
Type | Description |
---|---|
IntervalValue
|
An interval in units of |
to_timestamp(unit='s')
¶
Convert an integral UNIX timestamp to a timestamp expression.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
unit |
Literal['s', 'ms', 'us']
|
The resolution of |
's'
|
Returns:
Type | Description |
---|---|
TimestampValue
|
|
IntegerColumn
¶
Bases: NumericColumn
, IntegerValue
FloatingValue
¶
Bases: NumericValue
DecimalValue
¶
Bases: NumericValue
BooleanValue
¶
Bases: NumericValue
Functions¶
__and__(other)
¶
Construct a binary AND conditional expression with self
and other
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
Left operand |
required | |
other |
BooleanValue
|
Right operand |
required |
Returns:
Type | Description |
---|---|
BooleanValue
|
A Boolean expression |
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"arr": [[1], [], [42, 42], None]})
>>> t.arr.contains(42) & (t.arr.contains(1))
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ And(ArrayContains(arr, 42), ArrayContains(arr, 1)) ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ boolean │
├────────────────────────────────────────────────────┤
│ False │
│ False │
│ False │
│ NULL │
└────────────────────────────────────────────────────┘
>>> t.arr.contains(42) & (t.arr.contains(42))
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ And(ArrayContains(arr, 42), ArrayContains(arr, 42)) ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ boolean │
├─────────────────────────────────────────────────────┤
│ False │
│ False │
│ True │
│ NULL │
└─────────────────────────────────────────────────────┘
__invert__()
¶
Construct a unary NOT conditional expression with self
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
Operand |
required |
Returns:
Type | Description |
---|---|
BooleanValue
|
A Boolean expression |
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"arr": [True, False, False, None]})
>>> ~t.arr
┏━━━━━━━━━━┓
┃ Not(arr) ┃
┡━━━━━━━━━━┩
│ boolean │
├──────────┤
│ False │
│ True │
│ True │
│ NULL │
└──────────┘
__or__(other)
¶
Construct a binary OR conditional expression with self
and other
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
Left operand |
required | |
other |
BooleanValue
|
Right operand |
required |
Returns:
Type | Description |
---|---|
BooleanValue
|
A Boolean expression |
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"arr": [1, 2, 3, None]})
>>> (t.arr > 1) | (t.arr > 2)
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Or(Greater(arr, 1), Greater(arr, 2)) ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ boolean │
├──────────────────────────────────────┤
│ False │
│ True │
│ True │
│ NULL │
└──────────────────────────────────────┘
__xor__(other)
¶
Construct a binary XOR conditional expression with self
and other
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
Left operand |
required | |
other |
BooleanValue
|
Right operand |
required |
Returns:
Type | Description |
---|---|
BooleanValue
|
A Boolean expression |
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"arr": [1, 2, 3, None]})
>>> t.arr == 2
┏━━━━━━━━━━━━━━━━┓
┃ Equals(arr, 2) ┃
┡━━━━━━━━━━━━━━━━┩
│ boolean │
├────────────────┤
│ False │
│ True │
│ False │
│ NULL │
└────────────────┘
>>> (t.arr > 2)
┏━━━━━━━━━━━━━━━━━┓
┃ Greater(arr, 2) ┃
┡━━━━━━━━━━━━━━━━━┩
│ boolean │
├─────────────────┤
│ False │
│ False │
│ True │
│ NULL │
└─────────────────┘
>>> (t.arr == 2) ^ (t.arr > 2)
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Xor(Equals(arr, 2), Greater(arr, 2)) ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ boolean │
├──────────────────────────────────────┤
│ False │
│ True │
│ True │
│ NULL │
└──────────────────────────────────────┘
ifelse(true_expr, false_expr)
¶
Construct a ternary conditional expression.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
true_expr |
ir.Value
|
Expression to return if |
required |
false_expr |
ir.Value
|
Expression to return if |
required |
Returns:
Type | Description |
---|---|
Value
|
The value of |
Examples:
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"is_person": [True, False, True, None]})
>>> t.is_person.ifelse("yes", "no")
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Where(is_person, 'yes', 'no') ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ string │
├───────────────────────────────┤
│ yes │
│ no │
│ yes │
│ no │
└───────────────────────────────┘