Skip to content

Commit c7b3663

Browse files
committed
Update all aggregate functions to have an example usage that is correct
1 parent d7b3ab5 commit c7b3663

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

python/datafusion/functions.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,7 +1779,7 @@ def array_agg(
17791779
17801780
For example::
17811781
1782-
df.select(array_agg(col("a"), order_by="b"))
1782+
df.aggregate([], array_agg(col("a"), order_by="b"))
17831783
"""
17841784
order_by_raw = sort_list_to_raw_sort_list(order_by)
17851785
filter_raw = filter.expr if filter is not None else None
@@ -1941,7 +1941,7 @@ def median(
19411941

19421942

19431943
def min(expression: Expr, filter: Expr | None = None) -> Expr:
1944-
"""Returns the minimum value of the argument.
1944+
"""Aggregate function that returns the minimum value of the argument.
19451945
19461946
If using the builder functions described in ref:`_aggregation` this function ignores
19471947
the options ``order_by``, ``null_treatment``, and ``distinct``.
@@ -2268,11 +2268,6 @@ def first_value(
22682268
) -> Expr:
22692269
"""Returns the first value in a group of values.
22702270
2271-
.. note::
2272-
This is an aggregate function. It must be used within
2273-
:py:meth:`~datafusion.dataframe.DataFrame.aggregate` and generally cannot be
2274-
used with :py:meth:`~datafusion.dataframe.DataFrame.select`.
2275-
22762271
This aggregate function will return the first value in the partition.
22772272
22782273
If using the builder functions described in ref:`_aggregation` this function ignores
@@ -2287,7 +2282,7 @@ def first_value(
22872282
22882283
For example::
22892284
2290-
df.select(first_value(col("a"), order_by="ts"))
2285+
df.aggregate([], first_value(col("a"), order_by="ts"))
22912286
"""
22922287
order_by_raw = sort_list_to_raw_sort_list(order_by)
22932288
filter_raw = filter.expr if filter is not None else None
@@ -2324,7 +2319,7 @@ def last_value(
23242319
23252320
For example::
23262321
2327-
df.select(last_value(col("a"), order_by="ts"))
2322+
df.aggregate([], last_value(col("a"), order_by="ts"))
23282323
"""
23292324
order_by_raw = sort_list_to_raw_sort_list(order_by)
23302325
filter_raw = filter.expr if filter is not None else None
@@ -2363,7 +2358,7 @@ def nth_value(
23632358
23642359
For example::
23652360
2366-
df.select(nth_value(col("a"), 2, order_by="ts"))
2361+
df.aggregate([], nth_value(col("a"), 2, order_by="ts"))
23672362
"""
23682363
order_by_raw = sort_list_to_raw_sort_list(order_by)
23692364
filter_raw = filter.expr if filter is not None else None
@@ -2848,7 +2843,7 @@ def string_agg(
28482843
28492844
For example::
28502845
2851-
df.select(string_agg(col("a"), ",", order_by="b"))
2846+
df.aggregate([], string_agg(col("a"), ",", order_by="b"))
28522847
"""
28532848
order_by_raw = sort_list_to_raw_sort_list(order_by)
28542849
filter_raw = filter.expr if filter is not None else None

0 commit comments

Comments
 (0)