float() function

The float() function converts a single value to a float.

Output data type: Float

float(v: "3.14")



The value to convert.


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:

  1. Use map() to iterate over and update all input rows.
  2. Use float() to update the value of a column.

The following example uses data provided by the sampledata package.

import "sampledata"

data =
    |> rename(columns: {_value: "foo"})

    |> map(fn: (r) => ({r with foo: float(v:}))

View input and output

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.