Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Computes the inverse cosine (also known as arccosine) of the given column or expression. Supports Spark Connect.
For the corresponding Databricks SQL function, see acos function.
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.acos(col=<col>)
Parameters
| Parameter | Type | Description |
|---|---|---|
col |
pyspark.sql.Column or column name |
The target column or expression to compute the inverse cosine on. |
Returns
pyspark.sql.Column: A new column object representing the inverse cosine of the input.
Examples
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([(-1.0,), (-0.5,), (0.0,), (0.5,), (1.0,)], ["value"])
df.select("*", dbf.acos("value")).show()
+-----+------------------+
|value| ACOS(value)|
+-----+------------------+
| -1.0| 3.141592653589...|
| -0.5|2.0943951023931...|
| 0.0|1.5707963267948...|
| 0.5|1.0471975511965...|
| 1.0| 0.0|
+-----+------------------+
from pyspark.databricks.sql import functions as dbf
spark.sql(
"SELECT * FROM VALUES (-2), (2), (NULL) AS TAB(value)"
).select("*", dbf.acos("value")).show()
+-----+-----------+
|value|ACOS(value)|
+-----+-----------+
| -2| NaN|
| 2| NaN|
| NULL| NULL|
+-----+-----------+