vastorbit.VastColumn.get_len¶
- VastColumn.get_len() VastColumn¶
Returns a new
VastColumnthat represents the length of each element.- Returns:
VastColumn that includes the length of each element.
- Return type:
Examples
Let’s begin by importing vastorbit.
import vastorbit as vo
Hint
By assigning an alias to
vastorbit, we mitigate the risk of code collisions with other libraries. This precaution is necessary because vastorbit uses commonly known function names like “average” and “median”, which can potentially lead to naming conflicts. The use of an alias ensures that the functions fromvastorbitare used as intended without interfering with functions from other libraries.Let us create a dummy dataset with string values:
vdf = vo.VastFrame( { "val" : ['Hello', 'Meow', 'Gaza', 'New York'], }, )
AbcvalVarchar(8)1 Gaza 2 New York 3 Hello 4 Meow Rows: 1-4 | Column: val | Type: varchar(8)We can conveniently get the length of each row in a column:
vdf["val"].get_len()
123val.lengthBigint1 8 2 4 3 4 4 5 Rows: 4 | Column: val.length | Type: bigintNote
While the same task can be accomplished using pure SQL (see below), adopting a Pythonic approach can offer greater convenience and help avoid potential syntax errors.
vdf["val"] = "LENGTH(val)"
See also