sec
Computes secant of the input column. Supports Spark Connect.
For the corresponding Databricks SQL function, see sec function.
Syntax
Python
from pyspark.databricks.sql import functions as dbf
dbf.sec(col=<col>)
Parameters
Parameter | Type | Description |
|---|---|---|
|
| Angle in radians |
Returns
pyspark.sql.Column: Secant of the angle.
Examples
Python
from pyspark.databricks.sql import functions as dbf
spark.sql(
"SELECT * FROM VALUES (PI() / 4), (PI() / 16) AS TAB(value)"
).select("*", dbf.sec("value")).show()
Output
+-------------------+------------------+
| value| SEC(value)|
+-------------------+------------------+
| 0.7853981633974...| 1.414213562373...|
|0.19634954084936...|1.0195911582083...|
+-------------------+------------------+
Python
from pyspark.databricks.sql import functions as dbf
spark.sql(
"SELECT * FROM VALUES (FLOAT('NAN')), (NULL) AS TAB(value)"
).select("*", dbf.sec("value")).show()
Output
+-----+----------+
|value|SEC(value)|
+-----+----------+
| NaN| NaN|
| NULL| NULL|
+-----+----------+