float() function
The float()
function converts a single value to a float.
Output data type: Float
float(v: "3.14")
Parameters
v
The value to convert.
Examples
- Convert a string to a float value
- Convert a scientific notation string to a float value
- Convert an integer to a float value
- Convert all values in a column to float values
Convert a string to a float value
float(v: "3.14")
// Returns 3.14 (float)
Convert a scientific notation string to a float value
float(v: "1.23e+20")
// Returns 1.23e+20 (float)
Convert an integer to a float value
float(v: "10")
// Returns 10.0
Convert all values in a column to float values
If updating values in the _value
column, use toFloat()
.
To update values in columns other than _value
:
- Use
map()
to iterate over and update all input rows. - Use
float()
to update the value of a column.
The following example uses data provided by the sampledata
package.
import "sampledata"
data = sampledata.int()
|> rename(columns: {_value: "foo"})
data
|> map(fn: (r) => ({r with foo: float(v: r.foo)}))
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.