PyLegendInteger
Integer expression type in the PyLegend expression language.
PyLegendInteger represents an integer-valued column or computed
expression within a PyLegend query. It extends PyLegendNumber with
integer-specific arithmetic (+, -, *, %) that preserves
the integer type when both operands are integers, as well as bitwise
operators (&, |, ^, ~, <<, >>).
Instances are never constructed directly. They are produced by accessing
an integer column on a TDS frame — for example, frame["Order Id"] —
or by integer arithmetic on existing integer expressions.
PyLegendInteger inherits all mathematical functions from
PyLegendNumber (trigonometric, logarithmic, rounding, etc.) and
general-purpose methods from PyLegendPrimitive (equality, null
checks, string conversion, in_list).
__abs__
- PyLegendInteger.__abs__()[source]
Absolute value (
abs(expr)).- Returns:
The absolute value expression.
- Return type:
PyLegendInteger
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["abs_diff"] = abs(frame["Order Id"] - 10255) frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name abs_diff 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 7 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 6 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 5
__add__
- PyLegendInteger.__add__(other)[source]
Addition (
+).When both operands are integers, returns a
PyLegendInteger; otherwise falls back toPyLegendNumber.- Parameters:
other (
Union[int,float,PyLegendInteger,PyLegendFloat,PyLegendNumber]) – The right-hand operand.- Returns:
The sum expression.
- Return type:
Union[PyLegendNumber,PyLegendInteger]- Raises:
TypeError – If other is not a supported numeric type.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_plus_10"] = frame["Order Id"] + 10 frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_plus_10 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 10258 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 10259 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 10260
__and__
- PyLegendInteger.__and__(other)[source]
Bitwise AND (
&).- Parameters:
other (
Union[int,PyLegendInteger]) – The right-hand operand.- Returns:
The bitwise AND expression.
- Return type:
PyLegendInteger- Raises:
TypeError – If other is not an
intorPyLegendInteger.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["bit_and"] = frame["Order Id"] & 0xFF frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name bit_and 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 8 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 9 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 10
__ceil__
__eq__
- PyLegendPrimitive.__eq__(other)[source]
Test element-wise equality (
==).Compare this expression against another primitive value or expression. Returns a boolean expression that is
Truewhere the values are equal.- Parameters:
other (
Union[int,float,bool,str,date,datetime,Decimal,PyLegendPrimitive]) – The value or expression to compare against.- Returns:
A boolean expression representing the equality test.
- Return type:
PyLegendBoolean- Raises:
TypeError – If other is not a supported primitive type.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
# Filter rows where Ship Name equals a literal frame[frame["Ship Name"] == "Around the Horn"].head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name 0 10355 1996-11-15 1996-12-13 1996-11-20 Around the Horn 1 10383 1996-12-16 1997-01-13 1996-12-18 Around the Horn 2 10453 1997-02-21 1997-03-21 1997-02-26 Around the Horn
__floor__
__ge__
- PyLegendNumber.__ge__(other)[source]
Greater than or equal comparison (
>=).- Parameters:
other (
Union[int,float,PyLegendInteger,PyLegendFloat,PyLegendNumber]) – The right-hand operand.- Returns:
Truewhereself >= other.- Return type:
PyLegendBoolean- Raises:
TypeError – If other is not a supported numeric type.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame[frame["Order Id"] >= 10250].head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name 0 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 1 10251 1996-07-08 1996-08-05 1996-07-15 Victuailles en stock 2 10252 1996-07-09 1996-08-06 1996-07-11 Suprêmes délices
__gt__
- PyLegendNumber.__gt__(other)[source]
Greater than comparison (
>).- Parameters:
other (
Union[int,float,PyLegendInteger,PyLegendFloat,PyLegendNumber]) – The right-hand operand.- Returns:
Truewhereself > other.- Return type:
PyLegendBoolean- Raises:
TypeError – If other is not a supported numeric type.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame[frame["Order Id"] > 10250].head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name 0 10251 1996-07-08 1996-08-05 1996-07-15 Victuailles en stock 1 10252 1996-07-09 1996-08-06 1996-07-11 Suprêmes délices 2 10253 1996-07-10 1996-07-24 1996-07-16 Hanari Carnes
__invert__
- PyLegendInteger.__invert__()[source]
Bitwise NOT (
~expr).Flips all bits of the integer value.
- Returns:
The bitwise-inverted expression.
- Return type:
PyLegendInteger
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["bit_not"] = ~frame["Order Id"] frame.head(3).to_pandas()
__le__
- PyLegendNumber.__le__(other)[source]
Less than or equal comparison (
<=).- Parameters:
other (
Union[int,float,PyLegendInteger,PyLegendFloat,PyLegendNumber]) – The right-hand operand.- Returns:
Truewhereself <= other.- Return type:
PyLegendBoolean- Raises:
TypeError – If other is not a supported numeric type.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame[frame["Order Id"] <= 10250].head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes
__lshift__
- PyLegendInteger.__lshift__(other)[source]
Bitwise left shift (
<<).- Parameters:
other (
Union[int,PyLegendInteger]) – The number of positions to shift.- Returns:
The left-shifted expression.
- Return type:
PyLegendInteger- Raises:
TypeError – If other is not an
intorPyLegendInteger.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["shifted"] = frame["Order Id"] << 2 frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name shifted 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier -24544 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten -24540 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes -24536
__lt__
- PyLegendNumber.__lt__(other)[source]
Less than comparison (
<).- Parameters:
other (
Union[int,float,PyLegendInteger,PyLegendFloat,PyLegendNumber]) – The right-hand operand.- Returns:
Truewhereself < other.- Return type:
PyLegendBoolean- Raises:
TypeError – If other is not a supported numeric type.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame[frame["Order Id"] < 10250].head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten
__mod__
- PyLegendInteger.__mod__(other)[source]
Modulo (
%).- Parameters:
other (
Union[int,PyLegendInteger]) – The divisor.- Returns:
The remainder expression.
- Return type:
Union[PyLegendNumber,PyLegendInteger]- Raises:
TypeError – If other is not an
intorPyLegendInteger.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_mod_3"] = frame["Order Id"] % 3 frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_mod_3 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 0 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 1 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 2
__mul__
- PyLegendInteger.__mul__(other)[source]
Multiplication (
*).When both operands are integers, returns a
PyLegendInteger; otherwise falls back toPyLegendNumber.- Parameters:
other (
Union[int,float,PyLegendInteger,PyLegendFloat,PyLegendNumber]) – The right-hand operand.- Returns:
The product expression.
- Return type:
Union[PyLegendNumber,PyLegendInteger]- Raises:
TypeError – If other is not a supported numeric type.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_times_2"] = frame["Order Id"] * 2 frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_times_2 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 20496 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 20498 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 20500
__ne__
- PyLegendPrimitive.__ne__(other)[source]
Test element-wise inequality (
!=).Compare this expression against another primitive value or expression. Returns a boolean expression that is
Truewhere the values differ.- Parameters:
other (
Union[int,float,bool,str,date,datetime,Decimal,PyLegendPrimitive]) – The value or expression to compare against.- Returns:
A boolean expression representing the inequality test.
- Return type:
PyLegendBoolean- Raises:
TypeError – If other is not a supported primitive type.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
# Filter rows where Ship Name is not a specific value frame[frame["Ship Name"] != "Ship1"].head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes
__neg__
- PyLegendInteger.__neg__()[source]
Unary negation (
-expr).- Returns:
The negated expression.
- Return type:
PyLegendInteger
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["neg_id"] = -frame["Order Id"] frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name neg_id 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier -10248 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten -10249 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes -10250
__or__
- PyLegendInteger.__or__(other)[source]
Bitwise OR (
|).- Parameters:
other (
Union[int,PyLegendInteger]) – The right-hand operand.- Returns:
The bitwise OR expression.
- Return type:
PyLegendInteger- Raises:
TypeError – If other is not an
intorPyLegendInteger.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["bit_or"] = frame["Order Id"] | 0x0F frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name bit_or 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 10255 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 10255 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 10255
__pos__
__pow__
- PyLegendNumber.__pow__(other)[source]
Power / exponentiation (
**).- Parameters:
other (
Union[int,float,PyLegendInteger,PyLegendFloat,PyLegendNumber]) – The exponent.- Returns:
The power expression.
- Return type:
PyLegendNumber- Raises:
TypeError – If other is not a supported numeric type.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_squared"] = frame["Order Id"] ** 2 frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_squared 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 105021504.0 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 105042001.0 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 105062500.0
__radd__
- PyLegendInteger.__radd__(other)[source]
Reflected addition (
int + expr).Called when a Python literal is on the left side of
+.- Parameters:
other (
Union[int,float,PyLegendInteger,PyLegendFloat,PyLegendNumber]) – The left-hand operand.- Returns:
The sum expression.
- Return type:
Union[PyLegendNumber,PyLegendInteger]- Raises:
TypeError – If other is not a supported numeric type.
__rand__
__rlshift__
__rmod__
- PyLegendInteger.__rmod__(other)[source]
Reflected modulo (
int % expr).Called when a Python
intis on the left side of%.- Parameters:
other (
Union[int,PyLegendInteger]) – The left-hand operand (dividend).- Returns:
The remainder expression.
- Return type:
Union[PyLegendNumber,PyLegendInteger]- Raises:
TypeError – If other is not an
intorPyLegendInteger.
__rmul__
- PyLegendInteger.__rmul__(other)[source]
Reflected multiplication (
int * expr).Called when a Python literal is on the left side of
*.- Parameters:
other (
Union[int,float,PyLegendInteger,PyLegendFloat,PyLegendNumber]) – The left-hand operand.- Returns:
The product expression.
- Return type:
Union[PyLegendNumber,PyLegendInteger]- Raises:
TypeError – If other is not a supported numeric type.
__ror__
__round__
__rpow__
- PyLegendNumber.__rpow__(other)[source]
Reflected power (
int ** expr).Called when a Python literal is on the left side of
**. Behaves identically to__pow__()with swapped operand order.- Parameters:
other (
Union[int,float,PyLegendInteger,PyLegendFloat,PyLegendNumber]) – The base (left-hand operand).- Returns:
The power expression.
- Return type:
PyLegendNumber- Raises:
TypeError – If other is not a supported numeric type.
__rrshift__
__rshift__
- PyLegendInteger.__rshift__(other)[source]
Bitwise right shift (
>>).- Parameters:
other (
Union[int,PyLegendInteger]) – The number of positions to shift.- Returns:
The right-shifted expression.
- Return type:
PyLegendInteger- Raises:
TypeError – If other is not an
intorPyLegendInteger.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["shifted"] = frame["Order Id"] >> 2 frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name shifted 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 2562 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 2562 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 2562
__rsub__
- PyLegendInteger.__rsub__(other)[source]
Reflected subtraction (
int - expr).Called when a Python literal is on the left side of
-.- Parameters:
other (
Union[int,float,PyLegendInteger,PyLegendFloat,PyLegendNumber]) – The left-hand operand.- Returns:
The difference expression.
- Return type:
Union[PyLegendNumber,PyLegendInteger]- Raises:
TypeError – If other is not a supported numeric type.
__rtruediv__
- PyLegendNumber.__rtruediv__(other)[source]
Reflected true division (
int / expr).Called when a Python literal is on the left side of
/. Behaves identically to__truediv__()with swapped operand order.- Parameters:
other (
Union[int,float,PyLegendInteger,PyLegendFloat,PyLegendNumber]) – The dividend (left-hand operand).- Returns:
The quotient expression.
- Return type:
PyLegendNumber- Raises:
TypeError – If other is not a supported numeric type.
__rxor__
__sub__
- PyLegendInteger.__sub__(other)[source]
Subtraction (
-).When both operands are integers, returns a
PyLegendInteger; otherwise falls back toPyLegendNumber.- Parameters:
other (
Union[int,float,PyLegendInteger,PyLegendFloat,PyLegendNumber]) – The right-hand operand.- Returns:
The difference expression.
- Return type:
Union[PyLegendNumber,PyLegendInteger]- Raises:
TypeError – If other is not a supported numeric type.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_minus_10000"] = frame["Order Id"] - 10000 frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_minus_10000 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 248 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 249 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 250
__truediv__
- PyLegendNumber.__truediv__(other)[source]
True division (
/).- Parameters:
other (
Union[int,float,PyLegendInteger,PyLegendFloat,PyLegendNumber]) – The divisor.- Returns:
The quotient expression.
- Return type:
PyLegendNumber- Raises:
TypeError – If other is not a supported numeric type.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_half"] = frame["Order Id"] / 2 frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_half 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 5124.0 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 5124.5 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 5125.0
__xor__
- PyLegendInteger.__xor__(other)[source]
Bitwise XOR (
^).- Parameters:
other (
Union[int,PyLegendInteger]) – The right-hand operand.- Returns:
The bitwise XOR expression.
- Return type:
PyLegendInteger- Raises:
TypeError – If other is not an
intorPyLegendInteger.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["bit_xor"] = frame["Order Id"] ^ 0xFF frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name bit_xor 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 10487 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 10486 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 10485
acos
- PyLegendNumber.acos()[source]
Arc-cosine (inverse cosine). Result in radians.
- Returns:
The arc-cosine expression.
- Return type:
PyLegendNumber
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_acos"] = (frame["Order Id"] - 10248).acos() frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_acos 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 1.570796 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 0.0 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes <NA>
asin
- PyLegendNumber.asin()[source]
Arc-sine (inverse sine). Result in radians.
- Returns:
The arc-sine expression.
- Return type:
PyLegendNumber
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_asin"] = (frame["Order Id"] - 10248).asin() frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_asin 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 0.0 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 1.570796 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes <NA>
atan
- PyLegendNumber.atan()[source]
Arc-tangent (inverse tangent). Result in radians.
- Returns:
The arc-tangent expression.
- Return type:
PyLegendNumber
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_atan"] = frame["Order Id"].atan() frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_atan 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 1.570699 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 1.570699 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 1.570699
atan2
- PyLegendNumber.atan2(other)[source]
Two-argument arc-tangent (
atan2(self, other)).- Parameters:
other (
Union[int,float,PyLegendInteger,PyLegendFloat,PyLegendNumber]) – The second argument (x-coordinate).- Returns:
The arc-tangent expression (result in radians).
- Return type:
PyLegendNumber- Raises:
TypeError – If other is not a supported numeric type.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_atan2"] = frame["Order Id"].atan2(10000) frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_atan2 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 0.797646 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 0.797694 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 0.797743
cbrt
- PyLegendNumber.cbrt()[source]
Cube root.
- Returns:
The cube-root expression.
- Return type:
PyLegendNumber
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_cbrt"] = frame["Order Id"].cbrt() frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_cbrt 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 21.720994 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 21.721701 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 21.722407
ceil
- PyLegendNumber.ceil()[source]
Ceiling — smallest integer greater than or equal to the value.
- Returns:
The ceiling expression.
- Return type:
PyLegendInteger
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_ceil"] = (frame["Order Id"] / 3).ceil() frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_ceil 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 3416 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 3417 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 3417
cos
- PyLegendNumber.cos()[source]
Cosine (input in radians).
- Returns:
The cosine expression.
- Return type:
PyLegendNumber
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_cos"] = frame["Order Id"].cos() frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_cos 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 0.992227 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 0.431389 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes -0.526066
cosh
- PyLegendNumber.cosh()[source]
Hyperbolic cosine.
- Returns:
The hyperbolic cosine expression.
- Return type:
PyLegendNumber
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_cosh"] = (frame["Order Id"] - 10248).cosh() frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_cosh 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 1.0 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 1.543081 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 3.762196
cot
- PyLegendNumber.cot()[source]
Cotangent (input in radians).
- Returns:
The cotangent expression.
- Return type:
PyLegendNumber
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_cot"] = frame["Order Id"].cot() frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_cot 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 7.973502 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 0.478171 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes -0.618578
degrees
- PyLegendNumber.degrees()[source]
Convert radians to degrees.
- Returns:
The value in degrees.
- Return type:
PyLegendNumber
See also
radiansThe inverse conversion.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_deg"] = frame["Order Id"].degrees() frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_deg 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 587167.14845 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 587224.44423 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 587281.740009
exp
- PyLegendNumber.exp()[source]
Natural exponential (
e ** x).- Returns:
The exponential expression.
- Return type:
PyLegendNumber
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_exp"] = (frame["Order Id"] - 10248).exp() frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_exp 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 1.0 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 2.718282 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 7.389056
floor
- PyLegendNumber.floor()[source]
Floor — largest integer less than or equal to the value.
- Returns:
The floor expression.
- Return type:
PyLegendInteger
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_floor"] = (frame["Order Id"] / 3).floor() frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_floor 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 3416 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 3416 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 3416
in_list
- PyLegendPrimitive.in_list(lst)[source]
Test whether the value is contained in a list of values.
Returns a boolean expression equivalent to SQL
IN (...).- Parameters:
lst (
List[Union[int,float,bool,str,date,datetime,Decimal,PyLegendPrimitive]]) – A non-empty list of literal values or expressions to check membership against.- Returns:
Truewhere the value matches any element in lst.- Return type:
PyLegendBoolean- Raises:
ValueError – If lst is not a list or is empty.
TypeError – If any element in lst is not a supported primitive type.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
# Keep rows where Ship Name is one of several values frame[ frame["Ship Name"].in_list(["Hanari Carnes", "Victuailles en stock", "Suprêmes délices"]) ].head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name 0 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 1 10251 1996-07-08 1996-08-05 1996-07-15 Victuailles en stock 2 10252 1996-07-09 1996-08-06 1996-07-11 Suprêmes délices
is_empty
- PyLegendPrimitive.is_empty()[source]
Test whether the value is null / empty.
Returns a boolean expression that is
Truewhere the underlying column value isNULL.- Returns:
Truewhere the value is null.- Return type:
PyLegendBoolean
See also
is_not_emptyThe inverse test.
is_nullAlias for
is_empty.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
# Keep only rows where Ship Name is null frame[frame["Shipped Date"].is_empty()].head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name 0 11008 1998-04-08 1998-05-06 NaT Ernst Handel 1 11019 1998-04-13 1998-05-11 NaT Rancho grande 2 11039 1998-04-21 1998-05-19 NaT LINO-Delicateses
is_not_empty
- PyLegendPrimitive.is_not_empty()[source]
Test whether the value is not null / not empty.
Returns a boolean expression that is
Truewhere the underlying column value is notNULL.- Returns:
Truewhere the value is not null.- Return type:
PyLegendBoolean
See also
is_emptyThe inverse test.
is_not_nullAlias for
is_not_empty.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
# Keep only rows where Ship Name is present frame[frame["Ship Name"].is_not_empty()].head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes
is_not_null
- PyLegendPrimitive.is_not_null()[source]
Test whether the value is not null.
Alias for
is_not_empty().- Returns:
Truewhere the value is not null.- Return type:
PyLegendBoolean
See also
is_not_emptyCanonical not-null-check method.
is_nullThe inverse test.
is_null
- PyLegendPrimitive.is_null()[source]
Test whether the value is null.
Alias for
is_empty().- Returns:
Truewhere the value is null.- Return type:
PyLegendBoolean
See also
is_emptyCanonical null-check method.
is_not_nullThe inverse test.
log
- PyLegendNumber.log()[source]
Natural logarithm (
ln(x)).- Returns:
The natural-log expression.
- Return type:
PyLegendNumber
See also
log10Base-10 logarithm.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_log"] = frame["Order Id"].log() frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_log 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 9.234838 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 9.234935 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 9.235033
log10
- PyLegendNumber.log10()[source]
Base-10 logarithm.
- Returns:
The base-10 logarithm expression.
- Return type:
PyLegendNumber
See also
logNatural logarithm.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_log10"] = frame["Order Id"].log10() frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_log10 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 4.010639 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 4.010681 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 4.010724
radians
- PyLegendNumber.radians()[source]
Convert degrees to radians.
- Returns:
The value in radians.
- Return type:
PyLegendNumber
See also
degreesThe inverse conversion.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_rad"] = frame["Order Id"].radians() frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_rad 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 178.861342 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 178.878795 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 178.896248
rem
- PyLegendNumber.rem(other)[source]
Remainder (modulo for numeric expressions).
- Parameters:
other (
Union[int,float,PyLegendInteger,PyLegendFloat,PyLegendNumber]) – The divisor.- Returns:
The remainder expression.
- Return type:
PyLegendNumber- Raises:
TypeError – If other is not a supported numeric type.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_rem_3"] = frame["Order Id"].rem(3) frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_rem_3 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 0.0 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 1.0 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 2.0
round
- PyLegendNumber.round(n=None)[source]
Round to n decimal places.
- Parameters:
n (
Optional[int]) – Number of decimal places. Defaults to0(round to nearest integer).- Returns:
The rounded expression.
- Return type:
PyLegendNumber- Raises:
TypeError – If n is not an
int.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_round"] = (frame["Order Id"] / 3).round(2) frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_round 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 3416.0 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 3416.33 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 3416.67
sign
- PyLegendNumber.sign()[source]
Sign of the value (
-1,0, or1).- Returns:
-1for negative,0for zero,1for positive.- Return type:
PyLegendNumber
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_sign"] = (frame["Order Id"] - 10255).sign() frame.head(5).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_sign 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier -1.0 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten -1.0 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes -1.0 3 10251 1996-07-08 1996-08-05 1996-07-15 Victuailles en stock -1.0 4 10252 1996-07-09 1996-08-06 1996-07-11 Suprêmes délices -1.0
sin
- PyLegendNumber.sin()[source]
Sine (input in radians).
- Returns:
The sine expression.
- Return type:
PyLegendNumber
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_sin"] = frame["Order Id"].sin() frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_sin 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 0.124441 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 0.902166 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 0.850444
sinh
- PyLegendNumber.sinh()[source]
Hyperbolic sine.
- Returns:
The hyperbolic sine expression.
- Return type:
PyLegendNumber
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_sinh"] = (frame["Order Id"] - 10248).sinh() frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_sinh 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 0.0 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 1.175201 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 3.62686
sqrt
- PyLegendNumber.sqrt()[source]
Square root.
- Returns:
The square-root expression.
- Return type:
PyLegendNumber
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_sqrt"] = frame["Order Id"].sqrt() frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_sqrt 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 101.232406 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 101.237345 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 101.242284
tan
- PyLegendNumber.tan()[source]
Tangent (input in radians).
- Returns:
The tangent expression.
- Return type:
PyLegendNumber
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_tan"] = frame["Order Id"].tan() frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_tan 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 0.125415 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 2.091302 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes -1.616612
tanh
- PyLegendNumber.tanh()[source]
Hyperbolic tangent.
- Returns:
The hyperbolic tangent expression.
- Return type:
PyLegendNumber
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_tanh"] = (frame["Order Id"] - 10248).tanh() frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_tanh 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 0.0 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 0.761594 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 0.964028
to_decimal
- PyLegendNumber.to_decimal()[source]
Cast the value to a decimal expression.
- Returns:
The value as a decimal expression.
- Return type:
PyLegendDecimal
See also
to_floatCast to float instead.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_decimal"] = frame["Order Id"].to_decimal() frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_decimal 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 10248 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 10249 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 10250
to_float
- PyLegendNumber.to_float()[source]
Cast the value to a float expression.
- Returns:
The value as a float expression.
- Return type:
PyLegendFloat
See also
to_decimalCast to decimal instead.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["id_float"] = frame["Order Id"].to_float() frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name id_float 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 10248.0 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 10249.0 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 10250.0
to_string
- PyLegendPrimitive.to_string()[source]
Convert the value to its string representation.
Returns a string expression produced by applying the database’s
CAST(... AS TEXT)(SQL) or->toString()(Pure).- Returns:
The stringified expression.
- Return type:
PyLegendString
See also
toStringAlias for
to_string.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
# Convert an integer column to a string frame["order_str"] = frame["Order Id"].to_string() frame.head(3).to_pandas()
Order Id Order Date Required Date Shipped Date Ship Name order_str 0 10248 1996-07-04 1996-08-01 1996-07-16 Vins et alcools Chevalier 10248 1 10249 1996-07-05 1996-08-16 1996-07-10 Toms Spezialitäten 10249 2 10250 1996-07-08 1996-08-05 1996-07-12 Hanari Carnes 10250
toString
- PyLegendPrimitive.toString()[source]
Convert the value to its string representation.
Alias for
to_string().- Returns:
The stringified expression.
- Return type:
PyLegendString
See also
to_stringCanonical string-conversion method.