tan
Computes tangent of the input column. Supports Spark Connect.
For the corresponding Databricks SQL function, see tan function.
Syntax
Python
from pyspark.databricks.sql import functions as dbf
dbf.tan(col=<col>)
Parameters
Parameter | Type | Description |
|---|---|---|
|
| angle in radians |
Returns
pyspark.sql.Column: tangent of the given value, as if computed by java.lang.Math.tan()
Examples
Python
from pyspark.databricks.sql import functions as dbf
spark.sql(
"SELECT * FROM VALUES (0.0), (PI() / 4), (PI() / 6) AS TAB(value)"
).select("*", dbf.tan("value")).show()
Output
+------------------+------------------+
| value| TAN(value)|
+------------------+------------------+
| 0.0| 0.0|
|0.7853981633974...|0.9999999999999...|
|0.5235987755982...|0.5773502691896...|
+------------------+------------------+
Python
from pyspark.databricks.sql import functions as dbf
spark.sql(
"SELECT * FROM VALUES (FLOAT('NAN')), (NULL) AS TAB(value)"
).select("*", dbf.tan("value")).show()
Output
+-----+----------+
|value|TAN(value)|
+-----+----------+
| NaN| NaN|
| NULL| NULL|
+-----+----------+