Loading...

vastorbit.VastColumn.get_len

VastColumn.get_len() VastColumn

Returns a new VastColumn that represents the length of each element.

Returns:

VastColumn that includes the length of each element.

Return type:

VastColumn

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 from vastorbit are 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'],
    },
)
Abc
val
Varchar(8)
1Gaza
2New York
3Hello
4Meow
Rows: 1-4 | Column: val | Type: varchar(8)

We can conveniently get the length of each row in a column:

vdf["val"].get_len()
123
val.length
Bigint
18
24
34
45
Rows: 4 | Column: val.length | Type: bigint

Note

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

VastColumn.date_part() : Extracts a specific TS field from the VastColumn.