>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"values": [-1, 2, -3, 4]})
>>> t.values.abs()
┏━━━━━━━━━━━━━┓ ┃ Abs(values) ┃ ┡━━━━━━━━━━━━━┩ │ int64 │ ├─────────────┤ │ 1 │ │ 2 │ │ 3 │ │ 4 │ └─────────────┘
Integer, floating point, decimal, and boolean expressions.
expr.types.numeric.NumericValue()
Name | Description |
---|---|
abs | Return the absolute value of self . |
acos | Compute the arc cosine of self . |
asin | Compute the arc sine of self . |
atan | Compute the arc tangent of self . |
atan2 | Compute the two-argument version of arc tangent. |
ceil | Return the ceiling of self . |
clip | Trim values outside of lower and upper bounds. |
cos | Compute the cosine of self . |
cot | Compute the cotangent of self . |
degrees | Compute the degrees of self radians. |
exp | Compute \(e^\texttt{self}\). |
floor | Return the floor of an expression. |
ln | Compute \(\ln\left(\texttt{self}\right)\). |
log | Compute \(\log_{\texttt{base}}\left(\texttt{self}\right)\). |
log10 | Compute \(\log_{10}\left(\texttt{self}\right)\). |
log2 | Compute \(\log_{2}\left(\texttt{self}\right)\). |
negate | Negate a numeric expression. |
nullifzero | Return NULL if an expression is zero. |
point | Return a point constructed from the coordinate values. |
radians | Compute radians from self degrees. |
round | Round values to an indicated number of decimal places. |
sign | Return the sign of the input. |
sin | Compute the sine of self . |
sqrt | Compute the square root of self . |
tan | Compute the tangent of self . |
zeroifnull | Return zero if an expression is NULL . |
abs(self)
Return the absolute value of self
.
acos(self)
Compute the arc cosine of self
.
asin(self)
Compute the arc sine of self
.
atan(self)
Compute the arc tangent of self
.
atan2(self, other)
Compute the two-argument version of arc tangent.
ceil(self)
Return the ceiling of self
.
clip(self, lower=None, upper=None)
Trim values outside of lower
and upper
bounds.
Name | Type | Description | Default |
---|---|---|---|
lower |
NumericValue | None | Lower bound | None |
upper |
NumericValue | None | Upper bound | None |
Type | Description |
---|---|
NumericValue | Clipped input |
>>> 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(self)
Compute the cosine of self
.
cot(self)
Compute the cotangent of self
.
degrees(self)
Compute the degrees of self
radians.
>>> 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(self)
Compute \(e^\texttt{self}\).
Type | Description |
---|---|
NumericValue | \(e^\texttt{self}\) |
floor(self)
Return the floor of an expression.
ln(self)
Compute \(\ln\left(\texttt{self}\right)\).
log(self, base=None)
Compute \(\log_{\texttt{base}}\left(\texttt{self}\right)\).
Name | Type | Description | Default |
---|---|---|---|
base |
NumericValue | None | The base of the logarithm. If None , base e is used. |
None |
Type | Description |
---|---|
NumericValue | Logarithm of arg with base base |
log10(self)
Compute \(\log_{10}\left(\texttt{self}\right)\).
log2(self)
Compute \(\log_{2}\left(\texttt{self}\right)\).
negate(self)
Negate a numeric expression.
Type | Description |
---|---|
NumericValue | A numeric value expression |
nullifzero(self)
Return NULL
if an expression is zero.
point(self, right)
Return a point constructed from the coordinate values.
Constant coordinates result in construction of a POINT
literal or column.
Name | Type | Description | Default |
---|---|---|---|
right |
int | float | NumericValue | Y coordinate | required |
Type | Description |
---|---|
PointValue | Points |
radians(self)
Compute radians from self
degrees.
>>> 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(self, digits=None)
Round values to an indicated number of decimal places.
Name | Type | Description | Default |
---|---|---|---|
digits |
int | IntegerValue | None | The number of digits to round to. Here’s how the digits parameter affects the expression output type: - digits is False -y; self.type() is decimal → decimal - digits is nonzero; self.type() is decimal → decimal - digits is False -y; self.type() is Floating → int64 - digits is nonzero; self.type() is Floating → float64 |
None |
Type | Description |
---|---|
NumericValue | The rounded expression |
>>> 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 │ └─────────┘
┏━━━━━━━━━━━━━━━┓ ┃ Round(values) ┃ ┡━━━━━━━━━━━━━━━┩ │ int64 │ ├───────────────┤ │ 1 │ │ 2 │ │ 2 │ │ 3 │ └───────────────┘
sign(self)
Return the sign of the input.
sin(self)
Compute the sine of self
.
sqrt(self)
Compute the square root of self
.
tan(self)
Compute the tangent of self
.
zeroifnull(self)
Return zero if an expression is NULL
.
expr.types.numeric.NumericColumn()
Name | Description |
---|---|
bucket | Compute a discrete binning of a numeric array. |
corr | Return the correlation of two numeric columns. |
cov | Return the covariance of two numeric columns. |
cummean | Return the cumulative mean of the input. |
cumsum | Return the cumulative sum of the input. |
histogram | Compute a histogram with fixed width bins. |
mean | Return the mean of a numeric column. |
median | Return the median of the column. |
quantile | Return value at the given quantile. |
std | Return the standard deviation of a numeric column. |
sum | Return the sum of a numeric column. |
var | Return the variance of a numeric column. |
bucket(self, buckets, closed='left', close_extreme=True, include_under=False, include_over=False)
Compute a discrete binning of a numeric array.
Name | Type | Description | Default |
---|---|---|---|
buckets |
Sequence[int] | List of buckets | required |
closed |
Literal[‘left’, ‘right’] | Which side of each interval is closed. For example: python buckets = [0, 100, 200] closed = "left" # 100 falls in 2nd bucket closed = "right" # 100 falls in 1st bucket |
'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 |
Type | Description |
---|---|
IntegerColumn | A categorical column expression |
corr(self, right, where=None, how='sample')
Return the correlation of two numeric columns.
Name | Type | Description | Default |
---|---|---|---|
right |
NumericColumn | Numeric column | required |
where |
ir.BooleanValue | None | Filter | None |
how |
Literal[‘sample’, ‘pop’] | Population or sample correlation | 'sample' |
Type | Description |
---|---|
NumericScalar | The correlation of left and right |
cov(self, right, where=None, how='sample')
Return the covariance of two numeric columns.
Name | Type | Description | Default |
---|---|---|---|
right |
NumericColumn | Numeric column | required |
where |
ir.BooleanValue | None | Filter | None |
how |
Literal[‘sample’, ‘pop’] | Population or sample covariance | 'sample' |
Type | Description |
---|---|
NumericScalar | The covariance of self and right |
cummean(self)
Return the cumulative mean of the input.
cumsum(self)
Return the cumulative sum of the input.
histogram(self, nbins=None, binwidth=None, base=None, eps=1e-13)
Compute a histogram with fixed width bins.
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 column . |
None |
eps |
float | Allowed floating point epsilon for histogram base | 1e-13 |
Type | Description |
---|---|
Column | Bucketed column |
mean(self, where=None)
Return the mean of a numeric column.
Name | Type | Description | Default |
---|---|---|---|
where |
ir.BooleanValue | None | Filter | None |
Type | Description |
---|---|
NumericScalar | The mean of the input expression |
median(self, where=None)
Return the median of the column.
Name | Type | Description | Default |
---|---|---|---|
where |
ir.BooleanValue | None | Optional boolean expression. If given, only the values where where evaluates to true will be considered for the median. |
None |
Type | Description |
---|---|
NumericScalar | Median of the column |
quantile(self, quantile, interpolation=None, where=None)
Return value at the given quantile.
Name | Type | Description | Default |
---|---|---|---|
quantile |
Sequence[NumericValue | float] | 0 <= quantile <= 1 , the quantile(s) to compute |
required |
interpolation |
Literal[‘linear’, ‘lower’, ‘higher’, ‘midpoint’, ‘nearest’] | None | ::: {.callout-warning} ## 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 i and j : * linear: i + (j - i) * fraction , where fraction is the fractional part of the index surrounded by i and j . * lower: i . * higher: j . * nearest: i or j whichever is nearest. * midpoint: (i + j ) / 2. |
None |
where |
ir.BooleanValue | None | Boolean filter for input values | None |
Type | Description |
---|---|
NumericScalar | Quantile of the input |
std(self, where=None, how='sample')
Return the standard deviation of a numeric column.
Name | Type | Description | Default |
---|---|---|---|
where |
ir.BooleanValue | None | Filter | None |
how |
Literal[‘sample’, ‘pop’] | Sample or population standard deviation | 'sample' |
Type | Description |
---|---|
NumericScalar | Standard deviation of arg |
sum(self, where=None)
Return the sum of a numeric column.
Name | Type | Description | Default |
---|---|---|---|
where |
ir.BooleanValue | None | Filter | None |
Type | Description |
---|---|
NumericScalar | The sum of the input expression |
var(self, where=None, how='sample')
Return the variance of a numeric column.
Name | Type | Description | Default |
---|---|---|---|
where |
ir.BooleanValue | None | Filter | None |
how |
Literal[‘sample’, ‘pop’] | Sample or population variance | 'sample' |
Type | Description |
---|---|
NumericScalar | Standard deviation of arg |
expr.types.numeric.IntegerValue()
Name | Description |
---|---|
convert_base | Convert an integer from one base to another. |
label | Label a set of integer values with strings. |
to_interval | Convert an integer to an interval. |
to_timestamp | Convert an integral UNIX timestamp to a timestamp expression. |
convert_base(self, from_base, to_base)
Convert an integer from one base to another.
Name | Type | Description | Default |
---|---|---|---|
from_base |
IntegerValue | Numeric base of expression | required |
to_base |
IntegerValue | New base | required |
Type | Description |
---|---|
IntegerValue | Converted expression |
label(self, labels, nulls=None)
Label a set of integer values with strings.
Name | Type | Description | Default |
---|---|---|---|
labels |
Iterable[str] | An iterable of string labels. Each integer value in self will be mapped to a value in labels . |
required |
nulls |
str | None | String label to use for NULL values |
None |
Type | Description |
---|---|
StringValue | self labeled with labels |
>>> 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(self, unit='s')
Convert an integer to an interval.
Name | Type | Description | Default |
---|---|---|---|
unit |
Literal[‘Y’, ‘M’, ‘W’, ‘D’, ‘h’, ‘m’, ‘s’, ‘ms’, ‘us’, ‘ns’] | Unit for the resulting interval | 's' |
Type | Description |
---|---|
IntervalValue | An interval in units of unit |
to_timestamp(self, unit='s')
Convert an integral UNIX timestamp to a timestamp expression.
Name | Type | Description | Default |
---|---|---|---|
unit |
Literal[‘s’, ‘ms’, ‘us’] | The resolution of arg |
's' |
Type | Description |
---|---|
TimestampValue | self converted to a timestamp |
expr.types.numeric.IntegerColumn()
Name | Description |
---|---|
bit_and | Aggregate the column using the bitwise and operator. |
bit_or | Aggregate the column using the bitwise or operator. |
bit_xor | Aggregate the column using the bitwise exclusive or operator. |
bit_and(self, where=None)
Aggregate the column using the bitwise and operator.
bit_or(self, where=None)
Aggregate the column using the bitwise or operator.
bit_xor(self, where=None)
Aggregate the column using the bitwise exclusive or operator.
expr.types.numeric.FloatingValue()
Name | Description |
---|---|
isinf | Return whether the value is infinity. |
isnan | Return whether the value is NaN. |
isinf(self)
Return whether the value is infinity.
isnan(self)
Return whether the value is NaN.
expr.types.numeric.DecimalValue()
expr.types.logical.BooleanValue()
Name | Description |
---|---|
ifelse | Construct a ternary conditional expression. |
ifelse(self, true_expr, false_expr)
Construct a ternary conditional expression.
Name | Type | Description | Default |
---|---|---|---|
true_expr |
ir.Value | Expression to return if self evaluates to True |
required |
false_expr |
ir.Value | Expression to return if self evaluates to False or NULL |
required |
Type | Description |
---|---|
Value | The value of true_expr if arg is True else false_expr |
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"is_person": [True, False, True, None]})
>>> t.is_person.ifelse("yes", "no")
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ IfElse(is_person, 'yes', 'no') ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ string │ ├────────────────────────────────┤ │ yes │ │ no │ │ yes │ │ no │ └────────────────────────────────┘
expr.api.ifelse
Construct a ternary conditional expression.
Name | Type | Description | Default |
---|---|---|---|
condition |
ir.BooleanValue | A boolean expression | required |
true_expr |
ir.Value | Expression to return if condition evaluates to True |
required |
false_expr |
ir.Value | Expression to return if condition evaluates to False or NULL |
required |
Type | Description |
---|---|
ir.Value | The value of true_expr if condition is True else false_expr |
>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable({"is_person": [True, False, True, None]})
>>> ibis.ifelse(t.is_person, "yes", "no")
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ IfElse(is_person, 'yes', 'no') ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ string │ ├────────────────────────────────┤ │ yes │ │ no │ │ yes │ │ no │ └────────────────────────────────┘
and_(*predicates)
Combine multiple predicates using &
.
Name | Type | Description | Default |
---|---|---|---|
predicates |
ir.BooleanValue | Boolean value expressions | () |
Type | Description |
---|---|
BooleanValue | A new predicate that evaluates to True if all composing predicates are True. If no predicates were provided, returns True. |
or_(*predicates)
Combine multiple predicates using |
.
Name | Type | Description | Default |
---|---|---|---|
predicates |
ir.BooleanValue | Boolean value expressions | () |
Type | Description |
---|---|
BooleanValue | A new predicate that evaluates to True if any composing predicates are True. If no predicates were provided, returns False. |
expr.api.least
expr.api.greatest
expr.api.negate
random()
Return a random floating point number in the range [0.0, 1.0).
Similar to in the Python standard library.
Type | Description |
---|---|
FloatingScalar | Random float value expression |