zhengruifeng commented on code in PR #44794:
URL: https://github.com/apache/spark/pull/44794#discussion_r1458467248


##########
python/pyspark/sql/functions/builtin.py:
##########
@@ -1488,31 +1533,75 @@ def acos(col: "ColumnOrName") -> Column:
     Parameters
     ----------
     col : :class:`~pyspark.sql.Column` or str
-        target column to compute on.
+        The target column or expression to compute the inverse cosine on.
 
     Returns
     -------
     :class:`~pyspark.sql.Column`
-        inverse cosine of `col`, as if computed by `java.lang.Math.acos()`
+        A new column object representing the inverse cosine of the input.
 
     Examples
     --------
-    >>> df = spark.range(1, 3)
-    >>> df.select(acos(df.id)).show()
-    +--------+
-    |ACOS(id)|
-    +--------+
-    |     0.0|
-    |     NaN|
-    +--------+
+    Example 1: Compute the inverse cosine of a column of numbers
+
+    >>> from pyspark.sql import functions as sf
+    >>> df = spark.createDataFrame([(1, 0.5), (2, -0.5), (3, 1.0)], ["id", 
"value"])
+    >>> df.select(sf.acos(df.value)).show()
+    +------------------+
+    |       ACOS(value)|
+    +------------------+
+    |1.0471975511965979|

Review Comment:
   for trigonometric functions' example, what about making them use or return 
some special values? e.g.
   ```
   In [26]: df = spark.createDataFrame([(-1.0, 0.5), (-0.5, -0.5), (0.0, 1.0), 
(0.5, 0.0), (1.0, 1.0)], ["v1", "v2"])
   
   In [27]: df.select("v1", sf.acos("v1"), sf.degrees(sf.acos("v1"))).show()
   +----+------------------+------------------+
   |  v1|          ACOS(v1)| DEGREES(ACOS(v1))|
   +----+------------------+------------------+
   |-1.0| 3.141592653589...|             180.0|
   |-0.5|2.0943951023931...|120.00000000000...|
   | 0.0|1.5707963267948...|              90.0|
   | 0.5|1.0471975511965...| 60.00000000000...|
   | 1.0|               0.0|               0.0|
   +----+------------------+------------------+
   ```
   
   and we'd better use `...` at the last of numbers, since the computation 
result may vary slightly on different envs.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to