toInt() function
The toInt()
function converts all values in the _value
column to integers.
toInt()
Supported data types
- bool
- duration
- float
- string (numeric)
- time
- uinteger
toInt()
behavior depends on the _value
column data type:
_value type | Returned value |
---|---|
string | Integer equivalent of the numeric string |
bool | 1 (true) or 0 (false) |
duration | Number of nanoseconds in the specified duration |
time | Equivalent nanosecond epoch timestamp |
float | Value truncated at the decimal |
uint | Integer equivalent of the unsigned integer |
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.
Parameters
tables
Input data.
Default is piped-forward data (<-
).
Examples
The following examples use data provided by the sampledata
package
to show how toInt()
transforms data.
- Convert a float value column to an integer column
- Convert a boolean value column to an integer column
- Convert a uinteger value column to an integer column
Convert a float value column to an integer column
import "sampledata"
sampledata.float()
|> toInt()
Convert a boolean value column to an integer column
import "sampledata"
sampledata.bool()
|> toInt()
Convert a uinteger value column to an integer column
import "sampledata"
sampledata.uint()
|> toInt()
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for Flux and this documentation. To find support, the following resources are available:
InfluxDB Cloud customers can contact InfluxData Support.