kosiew commented on code in PR #1421:
URL: 
https://github.com/apache/datafusion-python/pull/1421#discussion_r2930274480


##########
python/datafusion/functions.py:
##########
@@ -607,12 +610,30 @@ def btrim(arg: Expr) -> Expr:
 
 
 def cbrt(arg: Expr) -> Expr:
-    """Returns the cube root of a number."""
+    """Returns the cube root of a number.
+
+    Examples:
+    ---------
+    >>> ctx = dfn.SessionContext()
+    >>> df = ctx.from_pydict({"a": [27]})
+    >>> cbrt_df = df.select(dfn.functions.cbrt(dfn.col("a")).alias("cbrt"))
+    >>> cbrt_df.collect_column("cbrt")[0].as_py()
+    3.0
+    """
     return Expr(f.cbrt(arg.expr))
 
 
 def ceil(arg: Expr) -> Expr:
-    """Returns the nearest integer greater than or equal to argument."""
+    """Returns the nearest integer greater than or equal to argument.
+
+    Examples:
+    ---------
+    >>> ctx = dfn.SessionContext()
+    >>> df = ctx.from_pydict({"a": [1.9]})
+    >>> floor_df = df.select(dfn.functions.ceil(dfn.col("a")).alias("ceil"))
+    >>> floor_df.collect_column("ceil")[0].as_py()

Review Comment:
   ceil_df would be less confusion.



##########
python/datafusion/functions.py:
##########
@@ -866,14 +1005,31 @@ def position(string: Expr, substring: Expr) -> Expr:
 
 
 def power(base: Expr, exponent: Expr) -> Expr:
-    """Returns ``base`` raised to the power of ``exponent``."""
+    """Returns ``base`` raised to the power of ``exponent``.
+
+    Examples:
+    ---------
+    >>> ctx = dfn.SessionContext()
+    >>> df = ctx.from_pydict({"a": [2.0]})
+    >>> result = df.select(dfn.functions.power(dfn.col("a"), 
dfn.lit(3.0)).alias("pow"))
+    >>> result.collect_column("pow")[0].as_py()
+    8.0
+    """
     return Expr(f.power(base.expr, exponent.expr))
 
 
 def pow(base: Expr, exponent: Expr) -> Expr:
     """Returns ``base`` raised to the power of ``exponent``.
 
     This is an alias of :py:func:`power`.
+
+    Examples:
+    ---------
+    >>> ctx = dfn.SessionContext()
+    >>> df = ctx.from_pydict({"a": [3.0]})
+    >>> result = df.select(dfn.functions.pow(dfn.col("a"), 
dfn.lit(2.0)).alias("pow"))
+    >>> result.collect_column("pow")[0].as_py()
+    9.0

Review Comment:
   The `pow` docstring already says it is an alias for `power`; duplicating a 
full example there may be more maintenance than value.



-- 
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