3.6 KiB
title | description | aliases | menu | weight | flux/v0.x/tags | related | introduced | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
toUInt() function | The `toUInt()` function converts all values in the `_value` column to UIntegers. |
|
|
102 |
|
|
0.7.0 |
The toUInt()
function converts all values in the _value
column to UIntegers.
toUInt()
{{% note %}}
To convert values in a column other than _value
, define a custom function
patterned after the function definition,
but replace _value
with your desired column.
{{% /note %}}
Supported data types
- bool
- duration
- float
- int
- string (numeric)
- time
toInt()
behavior depends on the _value
column data type:
_value type | Returned value |
---|---|
bool | 1 (true) or 0 (false) |
duration | Number of nanoseconds in the specified duration |
float | UInteger equivalent of the float value truncated at the decimal |
int | UInteger equivalent of the integer |
string | UInteger equivalent of the numeric string |
time | Equivalent nanosecond epoch timestamp |
Parameters
tables
Input data.
Default is piped-forward data (<-
).
Examples
{{% flux/sample-example-intro plural=true %}}
- Convert a float value column to a uinteger column
- Convert a boolean value column to a uinteger column
- Convert a uinteger value column to a integer column
Convert a float value column to a uinteger column
import "sampledata"
sampledata.float()
|> toUInt()
{{< expand-wrapper >}} {{% expand "View input and output" %}} {{< flex >}} {{% flex-content %}}
Input data
{{% flux/sample "float" %}}
{{% /flex-content %}} {{% flex-content %}}
Output data
{{% flux/sample "uint" %}}
{{% /flex-content %}} {{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}}
Convert a boolean value column to a uinteger column
import "sampledata"
sampledata.bool()
|> toUInt()
{{< expand-wrapper >}} {{% expand "View input and output" %}} {{< flex >}} {{% flex-content %}}
Input data
{{% flux/sample "bool" %}}
{{% /flex-content %}} {{% flex-content %}}
Output data
{{% flux/sample "numericBool" %}}
{{% /flex-content %}} {{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}}
Convert a uinteger value column to a integer column
import "sampledata"
sampledata.uint()
|> toUInt()
{{< expand-wrapper >}} {{% expand "View input and output" %}} {{< flex >}} {{% flex-content %}}
Input data
{{% flux/sample "uint" %}}
{{% /flex-content %}} {{% flex-content %}}
Output data
{{% flux/sample "int" %}}
{{% /flex-content %}} {{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}}