Base class for a data generating expression having a known type.
Methods 
 
asc Sort an expression ascending. 
 
between Check if this expression is between lower and upper, inclusive. 
 
case Create a SimpleCaseBuilder to chain multiple if-else statements. 
 
cases Create a case expression in one shot. 
 
cast Cast expression to indicated data type. 
 
coalesce Return the first non-null value from args. 
 
collect Aggregate this expression’s elements into an array. 
 
desc Sort an expression descending. 
 
fill_null Replace any null values with the indicated fill value. 
 
fillna Deprecated - use fill_null instead. 
 
group_concat Concatenate values using the indicated separator to produce a string. 
 
hash Compute an integer hash value. 
 
identical_to Return whether this expression is identical to other. 
 
isin Check whether this expression’s values are in values. 
 
isnull Return whether this expression is NULL. 
 
name Rename an expression to name. 
 
notin Check whether this expression’s values are not in values. 
 
notnull Return whether this expression is not NULL. 
 
nullif Set values to null if they equal the values null_if_expr. 
 
over Construct a window expression. 
 
substitute Replace values given in values with replacement. 
 
to_pandas Convert a column expression to a pandas Series or scalar object. 
 
try_cast Try cast expression to indicated data type. 
 
type Return the DataType  of self. 
 
typeof Return the string name of the datatype of self. 
 
 
asc 
Sort an expression ascending.
 
between 
Check if this expression is between lower and upper, inclusive.
Parameters 
 
lower 
Value Lower bound, inclusive 
required  
upper 
Value Upper bound, inclusive 
required  
 
 
Returns 
 
BooleanValue Expression indicating membership in the provided range 
 
 
 
Examples 
>>>  import  ibis>>>  ibis.options.interactive =  True >>>  t =  ibis.examples.penguins.fetch().limit(5 )>>>  t.bill_length_mm.between(35 , 38 )
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Between(bill_length_mm, 35, 38)  ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ boolean                          │
├─────────────────────────────────┤
│ False                           │
│ False                           │
│ False                           │
│ NULL                             │
│ True                            │
└─────────────────────────────────┘
 
 
 
 
 
case 
Create a SimpleCaseBuilder to chain multiple if-else statements.
Add new search expressions with the .when() method. These must be comparable with this column expression. Conclude by calling .end().
Examples 
>>>  import  ibis>>>  ibis.options.interactive =  True >>>  x =  ibis.examples.penguins.fetch().head(5 )["sex" ]>>>  x
┏━━━━━━━━┓
┃ sex     ┃
┡━━━━━━━━┩
│ string  │
├────────┤
│ male    │
│ female  │
│ female  │
│ NULL    │
│ female  │
└────────┘
 
 
 
>>>  x.case().when("male" , "M" ).when("female" , "F" ).else_("U" ).end()
/tmp/ipykernel_30155/2271248134.py:1: FutureWarning: `Value.case` is deprecated as of v10.0.0; use value.cases() or ibis.cases()
  x.case().when("male", "M").when("female", "F").else_("U").end() 
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ SimpleCase(sex, ('male', 'female'), ('M', 'F'), 'U')  ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ string                                                │
├──────────────────────────────────────────────────────┤
│ M                                                     │
│ F                                                     │
│ F                                                     │
│ U                                                     │
│ F                                                     │
└──────────────────────────────────────────────────────┘
 
 
 
Cases not given result in the ELSE case
>>>  x.case().when("male" , "M" ).else_("OTHER" ).end()
/tmp/ipykernel_30155/2674247010.py:1: FutureWarning: `Value.case` is deprecated as of v10.0.0; use value.cases() or ibis.cases()
  x.case().when("male", "M").else_("OTHER").end() 
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ SimpleCase(sex, ('male',), ('M',), 'OTHER')  ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ string                                       │
├─────────────────────────────────────────────┤
│ M                                            │
│ OTHER                                        │
│ OTHER                                        │
│ OTHER                                        │
│ OTHER                                        │
└─────────────────────────────────────────────┘
 
 
 
If you don’t supply an ELSE, then NULL is used
>>>  x.case().when("male" , "M" ).end()
/tmp/ipykernel_30155/1790570072.py:1: FutureWarning: `Value.case` is deprecated as of v10.0.0; use value.cases() or ibis.cases()
  x.case().when("male", "M").end() 
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ SimpleCase(sex, ('male',), ('M',), Cast(None, string))  ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ string                                                  │
├────────────────────────────────────────────────────────┤
│ M                                                       │
│ NULL                                                    │
│ NULL                                                    │
│ NULL                                                    │
│ NULL                                                    │
└────────────────────────────────────────────────────────┘
 
 
 
 
 
cases 
= None )Create a case expression in one shot.
Examples 
>>>  import  xorq.api as  xo>>>  xo.options.interactive =  True >>>  t =  xo.memtable({"values" : [1 , 2 , 1 , 2 , 3 , 2 , 4 ]})>>>  t
┏━━━━━━━━┓
┃ values  ┃
┡━━━━━━━━┩
│ int64   │
├────────┤
│      1  │
│      2  │
│      1  │
│      2  │
│      3  │
│      2  │
│      4  │
└────────┘
 
 
 
>>>  number_letter_map =  ((1 , "a" ), (2 , "b" ), (3 , "c" ))>>>  t.values.cases(number_letter_map, default= "unk" ).name("replace" )
┏━━━━━━━━━┓
┃ replace  ┃
┡━━━━━━━━━┩
│ string   │
├─────────┤
│ a        │
│ b        │
│ a        │
│ b        │
│ c        │
│ b        │
│ unk      │
└─────────┘
 
 
 
 
 
cast 
Cast expression to indicated data type.
Similar to pandas.Series.astype.
Parameters 
 
target_type 
Any Type to cast to. Anything accepted by ibis.dtype() 
required  
 
 
Examples 
>>>  import  ibis>>>  ibis.options.interactive =  True >>>  x =  ibis.examples.penguins.fetch()["bill_depth_mm" ]>>>  x
┏━━━━━━━━━━━━━━━┓
┃ bill_depth_mm  ┃
┡━━━━━━━━━━━━━━━┩
│ float64        │
├───────────────┤
│          18.7  │
│          17.4  │
│          18.0  │
│          NULL  │
│          19.3  │
│          20.6  │
│          17.8  │
│          19.6  │
│          18.1  │
│          20.2  │
│             …  │
└───────────────┘
 
 
 
python’s built-in types can be used
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Cast(bill_depth_mm, int64)  ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ int64                       │
├────────────────────────────┤
│                         19  │
│                         17  │
│                         18  │
│                       NULL  │
│                         19  │
│                         21  │
│                         18  │
│                         20  │
│                         18  │
│                         20  │
│                          …  │
└────────────────────────────┘
 
 
 
or string names
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Cast(bill_depth_mm, int8)  ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ int8                       │
├───────────────────────────┤
│                        19  │
│                        17  │
│                        18  │
│                      NULL  │
│                        19  │
│                        21  │
│                        18  │
│                        20  │
│                        18  │
│                        20  │
│                         …  │
└───────────────────────────┘
 
 
 
If you make an illegal cast, you won’t know until the backend actually executes it. Consider .try_cast()
>>>  ibis.literal("a string" ).cast("int64" )   
 
coalesce 
Return the first non-null value from args.
Parameters 
 
args 
Value Arguments from which to choose the first non-null value 
() 
 
 
Returns 
 
Value Coalesced expression 
 
 
 
Examples 
>>>  import  ibis>>>  ibis.coalesce(None , 4 , 5 ).name("x" ) 
 
 
collect 
= None , order_by= None , include_null= False )Aggregate this expression’s elements into an array.
This function is called array_agg, list_agg, or list in other systems.
Parameters 
 
where 
ir .BooleanValue  | NoneAn optional filter expression. If provided, only rows where where is True will be included in the aggregate. 
None 
order_by 
Any An ordering key (or keys) to use to order the rows before aggregating. If not provided, the order of the items in the result is undefined and backend specific. 
None 
include_null 
bool Whether to include null values when performing this aggregation. Set to True to include nulls in the result. 
False 
 
 
Examples 
Basic collect usage
>>>  import  ibis>>>  ibis.options.interactive =  True >>>  t =  ibis.memtable({"key" : list ("aaabb" ), "value" : [1 , 2 , 3 , 4 , 5 ]})>>>  t
┏━━━━━━━━┳━━━━━━━┓
┃ key     ┃ value  ┃
┡━━━━━━━━╇━━━━━━━┩
│ string  │ int64  │
├────────┼───────┤
│ a       │     1  │
│ a       │     2  │
│ a       │     3  │
│ b       │     4  │
│ b       │     5  │
└────────┴───────┘
 
 
 
┌────────────────┐
│ [ 1 , 2 , ...  +3 ]  │
└────────────────┘ 
 
 
 
>>>  type (t.value.collect())
ibis.expr.types.arrays.ArrayScalar 
 
Collect elements per group
>>>  t.group_by("key" ).agg(v= lambda  t: t.value.collect()).order_by("key" )
┏━━━━━━━━┳━━━━━━━━━━━━━━━━┓
┃ key     ┃ v               ┃
┡━━━━━━━━╇━━━━━━━━━━━━━━━━┩
│ string  │ array<int64>    │
├────────┼────────────────┤
│ a       │ [ 1 , 2 , ...  +1 ]  │
│ b       │ [ 4 , 5 ]          │
└────────┴────────────────┘
 
 
 
Collect elements per group using a filter
>>>  t.group_by("key" ).agg(v= lambda  t: t.value.collect(where= t.value >  1 )).order_by("key" )
┏━━━━━━━━┳━━━━━━━━━━━━━━┓
┃ key     ┃ v             ┃
┡━━━━━━━━╇━━━━━━━━━━━━━━┩
│ string  │ array<int64>  │
├────────┼──────────────┤
│ a       │ [ 2 , 3 ]        │
│ b       │ [ 4 , 5 ]        │
└────────┴──────────────┘
 
 
 
 
 
desc 
Sort an expression descending.
 
fill_null 
Replace any null values with the indicated fill value.
Parameters 
 
fill_value 
Scalar Value with which to replace NULL values in self 
required  
 
 
Examples 
>>>  import  ibis>>>  ibis.options.interactive =  True >>>  t =  ibis.examples.penguins.fetch().limit(5 )>>>  t.sex
┏━━━━━━━━┓
┃ sex     ┃
┡━━━━━━━━┩
│ string  │
├────────┤
│ male    │
│ female  │
│ female  │
│ NULL    │
│ female  │
└────────┘
 
 
 
>>>  t.sex.fill_null("unrecorded" ).name("sex" )
┏━━━━━━━━━━━━┓
┃ sex         ┃
┡━━━━━━━━━━━━┩
│ string      │
├────────────┤
│ male        │
│ female      │
│ female      │
│ unrecorded  │
│ female      │
└────────────┘
 
 
 
 
Returns 
 
Value self filled with fill_value where it is NULL 
 
 
 
fillna 
Deprecated - use fill_null instead.
 
group_concat 
= ',' , where= None , order_by= None )Concatenate values using the indicated separator to produce a string.
Parameters 
 
sep 
str The separator to use to join strings. 
',' 
where 
ir .BooleanValue  | NoneAn optional filter expression. If provided, only rows where where is True will be included in the aggregate. 
None 
order_by 
Any An ordering key (or keys) to use to order the rows before aggregating. If not provided, the order of the items in the result is undefined and backend specific. 
None 
 
 
Examples 
>>>  import  ibis>>>  ibis.options.interactive =  True >>>  t =  ibis.examples.penguins.fetch().limit(5 )>>>  t[["bill_length_mm" , "bill_depth_mm" ]]
┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ bill_length_mm  ┃ bill_depth_mm  ┃
┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ float64         │ float64        │
├────────────────┼───────────────┤
│           39.1  │          18.7  │
│           39.5  │          17.4  │
│           40.3  │          18.0  │
│           NULL  │          NULL  │
│           36.7  │          19.3  │
└────────────────┴───────────────┘
 
 
 
>>>  t.bill_length_mm.group_concat()
┌─────────────────────┐
│ 39.1,39.5,40.3,36.7  │
└─────────────────────┘ 
 
 
 
>>>  t.bill_length_mm.group_concat(sep= ": " )
┌────────────────────────┐
│ 39.1: 39.5: 40.3: 36.7  │
└────────────────────────┘ 
 
 
 
>>>  t.bill_length_mm.group_concat(sep= ": " , where= t.bill_depth_mm >  18 )
┌────────────┐
│ 39.1: 36.7  │
└────────────┘ 
 
 
 
 
 
hash 
Compute an integer hash value.
Examples 
>>>  import  ibis>>>  ibis.options.interactive =  True >>>  ibis.literal("hello" ).hash ()
┌─────────────────────┐
│ 8628213525773890682  │
└─────────────────────┘ 
 
 
 
 
 
identical_to 
Return whether this expression is identical to other.
Corresponds to IS NOT DISTINCT FROM in SQL.
Parameters 
 
other 
Value Expression to compare to 
required  
 
 
Returns 
 
BooleanValue Whether this expression is not distinct from other 
 
 
 
Examples 
>>>  import  ibis>>>  ibis.options.interactive =  True >>>  one =  ibis.literal(1 )>>>  two =  ibis.literal(2 )>>>  two.identical_to(one +  one)
┌──────┐
│ True │
└──────┘ 
 
 
 
isin 
Check whether this expression’s values are in values.
NULL values are propagated in the output. See examples for details.
Examples 
>>>  import  ibis>>>  ibis.options.interactive =  True >>>  t =  ibis.memtable({"a" : [1 , 2 , 3 ], "b" : [2 , 3 , 4 ]})>>>  t
┏━━━━━━━┳━━━━━━━┓
┃ a      ┃ b      ┃
┡━━━━━━━╇━━━━━━━┩
│ int64  │ int64  │
├───────┼───────┤
│     1  │     2  │
│     2  │     3  │
│     3  │     4  │
└───────┴───────┘
 
 
 
Check against a literal sequence of values
┏━━━━━━━━━━━━━━━━━━━━━┓
┃ InValues(a, (1, 2))  ┃
┡━━━━━━━━━━━━━━━━━━━━━┩
│ boolean              │
├─────────────────────┤
│ True                │
│ True                │
│ False               │
└─────────────────────┘
 
 
 
Check against a derived expression
┏━━━━━━━━━━━━━━━┓
┃ InSubquery(a)  ┃
┡━━━━━━━━━━━━━━━┩
│ boolean        │
├───────────────┤
│ False         │
│ False         │
│ True          │
└───────────────┘
 
 
 
Check against a column from a different table
>>>  t2 =  ibis.memtable({"x" : [99 , 2 , 99 ]})>>>  t.a.isin(t2.x)
┏━━━━━━━━━━━━━━━┓
┃ InSubquery(a)  ┃
┡━━━━━━━━━━━━━━━┩
│ boolean        │
├───────────────┤
│ False         │
│ True          │
│ False         │
└───────────────┘
 
 
 
NULL behavior
>>>  t =  ibis.memtable({"x" : [1 , 2 ]})>>>  t.x.isin([1 , None ])
┏━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ InValues(x, (1, None))  ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━┩
│ boolean                 │
├────────────────────────┤
│ True                   │
│ NULL                    │
└────────────────────────┘
 
 
 
>>>  t =  ibis.memtable({"x" : [1 , None , 2 ]})>>>  t.x.isin([1 ])
┏━━━━━━━━━━━━━━━━━━━┓
┃ InValues(x, (1,))  ┃
┡━━━━━━━━━━━━━━━━━━━┩
│ boolean            │
├───────────────────┤
│ True              │
│ NULL               │
│ False             │
└───────────────────┘
 
 
 
┏━━━━━━━━━━━━━━━━━━━┓
┃ InValues(x, (3,))  ┃
┡━━━━━━━━━━━━━━━━━━━┩
│ boolean            │
├───────────────────┤
│ False             │
│ NULL               │
│ False             │
└───────────────────┘
 
 
 
 
 
isnull 
Return whether this expression is NULL.
Examples 
>>>  import  ibis>>>  ibis.options.interactive =  True >>>  t =  ibis.examples.penguins.fetch().limit(5 )>>>  t.bill_depth_mm
┏━━━━━━━━━━━━━━━┓
┃ bill_depth_mm  ┃
┡━━━━━━━━━━━━━━━┩
│ float64        │
├───────────────┤
│          18.7  │
│          17.4  │
│          18.0  │
│          NULL  │
│          19.3  │
└───────────────┘
 
 
 
>>>  t.bill_depth_mm.isnull()
┏━━━━━━━━━━━━━━━━━━━━━━━┓
┃ IsNull(bill_depth_mm)  ┃
┡━━━━━━━━━━━━━━━━━━━━━━━┩
│ boolean                │
├───────────────────────┤
│ False                 │
│ False                 │
│ False                 │
│ True                  │
│ False                 │
└───────────────────────┘
 
 
 
 
 
name 
Rename an expression to name.
Parameters 
 
name 
The new name of the expression 
required  
 
 
Returns 
 
Value self with name name 
 
 
Examples 
>>>  import  ibis>>>  ibis.options.interactive =  True >>>  t =  ibis.memtable({"a" : [1 , 2 ]}, name= "t" )>>>  t.a
┏━━━━━━━┓
┃ a      ┃
┡━━━━━━━┩
│ int64  │
├───────┤
│     1  │
│     2  │
└───────┘
 
 
 
┏━━━━━━━┓
┃ b      ┃
┡━━━━━━━┩
│ int64  │
├───────┤
│     1  │
│     2  │
└───────┘
 
 
 
 
 
notin 
Check whether this expression’s values are not in values.
Opposite of Value.isin()
Parameters 
 
values 
Value  | Sequence [Value ]Values or expression to check for lack of membership 
required  
 
 
Returns 
 
BooleanValue Whether self’s values are not contained in values 
 
 
 
Examples 
>>>  import  ibis>>>  ibis.options.interactive =  True >>>  t =  ibis.examples.penguins.fetch().limit(5 )>>>  t.bill_depth_mm
┏━━━━━━━━━━━━━━━┓
┃ bill_depth_mm  ┃
┡━━━━━━━━━━━━━━━┩
│ float64        │
├───────────────┤
│          18.7  │
│          17.4  │
│          18.0  │
│          NULL  │
│          19.3  │
└───────────────┘
 
 
 
>>>  t.bill_depth_mm.notin([18.7 , 18.1 ])
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Not(InValues(bill_depth_mm, (18.7, 18.1)))  ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ boolean                                     │
├────────────────────────────────────────────┤
│ False                                      │
│ True                                       │
│ True                                       │
│ NULL                                        │
│ True                                       │
└────────────────────────────────────────────┘
 
 
 
 
 
notnull 
Return whether this expression is not NULL.
Examples 
>>>  import  ibis>>>  ibis.options.interactive =  True >>>  t =  ibis.examples.penguins.fetch().limit(5 )>>>  t.bill_depth_mm
┏━━━━━━━━━━━━━━━┓
┃ bill_depth_mm  ┃
┡━━━━━━━━━━━━━━━┩
│ float64        │
├───────────────┤
│          18.7  │
│          17.4  │
│          18.0  │
│          NULL  │
│          19.3  │
└───────────────┘
 
 
 
>>>  t.bill_depth_mm.notnull()
┏━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ NotNull(bill_depth_mm)  ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━┩
│ boolean                 │
├────────────────────────┤
│ True                   │
│ True                   │
│ True                   │
│ False                  │
│ True                   │
└────────────────────────┘
 
 
 
 
 
nullif 
Set values to null if they equal the values null_if_expr.
Commonly used to avoid divide-by-zero problems by replacing zero with NULL in the divisor.
Equivalent to (self == null_if_expr).ifelse(ibis.null(), self).
Parameters 
 
null_if_expr 
Value Expression indicating what values should be NULL 
required  
 
 
Examples 
>>>  import  ibis>>>  ibis.options.interactive =  True >>>  vals =  ibis.examples.penguins.fetch().head(5 ).sex>>>  vals
┏━━━━━━━━┓
┃ sex     ┃
┡━━━━━━━━┩
│ string  │
├────────┤
│ male    │
│ female  │
│ female  │
│ NULL    │
│ female  │
└────────┘
 
 
 
┏━━━━━━━━━━━━━━━━━━━━━┓
┃ NullIf(sex, 'male')  ┃
┡━━━━━━━━━━━━━━━━━━━━━┩
│ string               │
├─────────────────────┤
│ NULL                 │
│ female               │
│ female               │
│ NULL                 │
│ female               │
└─────────────────────┘
 
 
 
 
 
over 
= None , * , rows= None , range = None , group_by= None , order_by= None )Construct a window expression.
Parameters 
 
 
window 
Window specification 
None 
rows 
Whether to use the ROWS window clause 
None 
range 
Whether to use the RANGE window clause 
None 
group_by 
Grouping key 
None 
order_by 
Ordering key 
None 
 
 
Returns 
 
Value A window function expression 
 
 
 
 
substitute 
= None , else_= None )Replace values given in values with replacement.
This is similar to the pandas replace method.
Parameters 
 
value 
Value  | dict Expression or dict. 
required  
replacement 
Value  | NoneIf an expression is passed to value, this must be passed. 
None 
else_ 
Value  | NoneIf an original value does not match value, then else_ is used. The default of None means leave the original value unchanged. 
None 
 
 
Examples 
>>>  import  ibis>>>  ibis.options.interactive =  True >>>  t =  ibis.examples.penguins.fetch()>>>  t.island.value_counts().order_by("island" )
┏━━━━━━━━━━━┳━━━━━━━━━━━━━━┓
┃ island     ┃ island_count  ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━━━┩
│ string     │ int64         │
├───────────┼──────────────┤
│ Biscoe     │          168  │
│ Dream      │          124  │
│ Torgersen  │           52  │
└───────────┴──────────────┘
 
 
 
>>>  t.island.substitute({"Torgersen" : "torg" , "Biscoe" : "bisc" }).name("island" "island" )
┏━━━━━━━━┳━━━━━━━━━━━━━━┓
┃ island  ┃ island_count  ┃
┡━━━━━━━━╇━━━━━━━━━━━━━━┩
│ string  │ int64         │
├────────┼──────────────┤
│ Dream   │          124  │
│ bisc    │          168  │
│ torg    │           52  │
└────────┴──────────────┘
 
 
 
 
 
to_pandas 
Convert a column expression to a pandas Series or scalar object.
Parameters 
 
kwargs 
Same as keyword arguments to execute 
{} 
 
 
Examples 
>>>  import  ibis>>>  ibis.options.interactive =  True >>>  t =  ibis.examples.penguins.fetch().limit(5 )>>>  t.to_pandas()
 
0 
Adelie 
Torgersen 
39.1 
18.7 
181.0 
3750.0 
male 
2007 
 
1 
Adelie 
Torgersen 
39.5 
17.4 
186.0 
3800.0 
female 
2007 
 
2 
Adelie 
Torgersen 
40.3 
18.0 
195.0 
3250.0 
female 
2007 
 
3 
Adelie 
Torgersen 
NaN 
NaN 
NaN 
NaN 
None 
2007 
 
4 
Adelie 
Torgersen 
36.7 
19.3 
193.0 
3450.0 
female 
2007 
 
 
 
 
 
 
 
try_cast 
Try cast expression to indicated data type.
If the cast fails for a row, the value is returned as null or NaN depending on target_type and backend behavior.
Parameters 
 
target_type 
Any Type to try cast to. Anything accepted by ibis.dtype() 
required  
 
 
Examples 
>>>  import  ibis>>>  from  ibis import  _>>>  ibis.options.interactive =  True >>>  t =  ibis.memtable({"numbers" : [1 , 2 , 3 , 4 ], "strings" : ["1.0" , "2" , "hello" , "world" ]})>>>  t
┏━━━━━━━━━┳━━━━━━━━━┓
┃ numbers  ┃ strings  ┃
┡━━━━━━━━━╇━━━━━━━━━┩
│ int64    │ string   │
├─────────┼─────────┤
│       1  │ 1.0      │
│       2  │ 2        │
│       3  │ hello    │
│       4  │ world    │
└─────────┴─────────┘
 
 
 
>>>  t =  t.mutate(numbers_to_strings= _.numbers.try_cast("string" ))>>>  t =  t.mutate(strings_to_numbers= _.strings.try_cast("int" ))>>>  t
┏━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┓
┃ numbers  ┃ strings  ┃ numbers_to_strings  ┃ strings_to_numbers  ┃
┡━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━┩
│ int64    │ string   │ string              │ int64               │
├─────────┼─────────┼────────────────────┼────────────────────┤
│       1  │ 1.0      │ 1                   │                  1  │
│       2  │ 2        │ 2                   │                  2  │
│       3  │ hello    │ 3                   │               NULL  │
│       4  │ world    │ 4                   │               NULL  │
└─────────┴─────────┴────────────────────┴────────────────────┘
 
 
 
 
 
typeof 
Return the string name of the datatype of self.
The values of the returned strings are necessarily backend dependent. e.g. duckdb may say “DOUBLE”, while sqlite may say “real”.
Examples 
>>>  import  ibis>>>  ibis.options.interactive =  True >>>  vals =  ibis.examples.penguins.fetch().head(5 ).bill_length_mm>>>  vals
┏━━━━━━━━━━━━━━━━┓
┃ bill_length_mm  ┃
┡━━━━━━━━━━━━━━━━┩
│ float64         │
├────────────────┤
│           39.1  │
│           39.5  │
│           40.3  │
│           NULL  │
│           36.7  │
└────────────────┘
 
 
 
┏━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ TypeOf(bill_length_mm)  ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━┩
│ string                  │
├────────────────────────┤
│ DOUBLE                  │
│ DOUBLE                  │
│ DOUBLE                  │
│ DOUBLE                  │
│ DOUBLE                  │
└────────────────────────┘
 
 
 
Different backends have different names for their native types
>>>  ibis.duckdb.connect ().execute(ibis.literal(5.4 ).typeof()) 
>>>  ibis.sqlite.connect ().execute(ibis.literal(5.4 ).typeof())