snowflake.snowpark.functions.array_remove_at¶
- snowflake.snowpark.functions.array_remove_at(array: Union[snowflake.snowpark.column.Column, str], position: Union[snowflake.snowpark.column.Column, str]) Column[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.40.0/src/snowflake/snowpark/_functions/scalar_functions.py#L768-L792)¶
Returns an ARRAY with the element at the specified position removed.
- Parameters:
array (ColumnOrName) – Column containing the source ARRAY.
position (ColumnOrName) – Column containing a (zero-based) position in the source ARRAY. The element at this position is removed from the resulting ARRAY. A negative position is interpreted as an index from the back of the array (e.g. -1 removes the last element in the array).
- Returns:
The resulting ARRAY with the specified element removed.
- Return type:
Example:
>>> df = session.create_dataframe([([2, 5, 7], 0), ([2, 5, 7], -1), ([2, 5, 7], 10)], schema=["array_col", "position_col"]) >>> df.select(array_remove_at("array_col", "position_col").alias("result")).collect() [Row(RESULT='[\n 5,\n 7\n]'), Row(RESULT='[\n 2,\n 5\n]'), Row(RESULT='[\n 2,\n 5,\n 7\n]')]