Skip to content

Commit

Permalink
Amend list_ to array_ in documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
kosiew committed Nov 12, 2024
1 parent 28e677d commit 0aee7c7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions docs/source/user-guide/common-operations/expressions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,31 +110,31 @@ This function returns an integer indicating the total number of elements in the
In this example, the `num_elements` column will contain `3` for both rows.

To concatenate two arrays, you can use the function :py:func:`datafusion.functions.list_cat` or :py:func:`datafusion.functions.list_concat`.
To concatenate two arrays, you can use the function :py:func:`datafusion.functions.array_cat` or :py:func:`datafusion.functions.array_concat`.
These functions return a new array that is the concatenation of the input arrays.

.. ipython:: python
from datafusion import SessionContext, col
from datafusion.functions import list_cat, list_concat
from datafusion.functions import array_cat, array_concat
ctx = SessionContext()
df = ctx.from_pydict({"a": [[1, 2, 3]], "b": [[4, 5, 6]]})
df.select(list_cat(col("a"), col("b")).alias("concatenated_array"))
df.select(array_cat(col("a"), col("b")).alias("concatenated_array"))
In this example, the `concatenated_array` column will contain `[1, 2, 3, 4, 5, 6]`.

To repeat the elements of an array a specified number of times, you can use the function :py:func:`datafusion.functions.list_repeat`.
To repeat the elements of an array a specified number of times, you can use the function :py:func:`datafusion.functions.array_repeat`.
This function returns a new array with the elements repeated.

.. ipython:: python
from datafusion import SessionContext, col, literal
from datafusion.functions import list_repeat
from datafusion.functions import array_repeat
ctx = SessionContext()
df = ctx.from_pydict({"a": [[1, 2, 3]]})
df.select(list_repeat(col("a"), literal(2)).alias("repeated_array"))
df.select(array_repeat(col("a"), literal(2)).alias("repeated_array"))
In this example, the `repeated_array` column will contain `[[1, 2, 3], [1, 2, 3]]`.

Expand Down

0 comments on commit 0aee7c7

Please sign in to comment.