pyspark.sql.functions.tan#
- pyspark.sql.functions.tan(col)[source]#
- Computes tangent of the input column. - New in version 1.4.0. - Changed in version 3.4.0: Supports Spark Connect. - Parameters
- colColumnor column name
- angle in radians 
 
- col
- Returns
- Column
- tangent of the given value, as if computed by java.lang.Math.tan() 
 
 - Examples - Example 1: Compute the tangent - >>> from pyspark.sql import functions as sf >>> spark.sql( ... "SELECT * FROM VALUES (0.0), (PI() / 4), (PI() / 6) AS TAB(value)" ... ).select("*", sf.tan("value")).show() +------------------+------------------+ | value| TAN(value)| +------------------+------------------+ | 0.0| 0.0| |0.7853981633974...|0.9999999999999...| |0.5235987755982...|0.5773502691896...| +------------------+------------------+ - Example 2: Compute the tangent of invalid values - >>> from pyspark.sql import functions as sf >>> spark.sql( ... "SELECT * FROM VALUES (FLOAT('NAN')), (NULL) AS TAB(value)" ... ).select("*", sf.tan("value")).show() +-----+----------+ |value|TAN(value)| +-----+----------+ | NaN| NaN| | NULL| NULL| +-----+----------+