pyspark.sql.functions.atan#
- pyspark.sql.functions.atan(col)[source]#
Compute inverse tangent of the input column.
New in version 1.4.0.
Changed in version 3.4.0: Supports Spark Connect.
- Parameters
- col
Column
or column name target column to compute on.
- col
- Returns
Column
inverse tangent of col, as if computed by java.lang.Math.atan()
Examples
Example 1: Compute the inverse tangent
>>> from pyspark.sql import functions as sf >>> df = spark.createDataFrame([(-0.5,), (0.0,), (0.5,)], ["value"]) >>> df.select("*", sf.atan(df.value)).show() +-----+-------------------+ |value| ATAN(value)| +-----+-------------------+ | -0.5|-0.4636476090008...| | 0.0| 0.0| | 0.5| 0.4636476090008...| +-----+-------------------+
Example 2: Compute the inverse tangent of invalid values
>>> from pyspark.sql import functions as sf >>> spark.sql( ... "SELECT * FROM VALUES (FLOAT('NAN')), (NULL) AS TAB(value)" ... ).select("*", sf.atan("value")).show() +-----+-----------+ |value|ATAN(value)| +-----+-----------+ | NaN| NaN| | NULL| NULL| +-----+-----------+