From c2e8d9dd3b34cafe2bb1dce0aba8b1812e5a13b6 Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Sun, 19 Nov 2023 09:11:46 -0500 Subject: [PATCH] feat(pandas/dask): implement flatten --- ibis/backends/pandas/execution/arrays.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ibis/backends/pandas/execution/arrays.py b/ibis/backends/pandas/execution/arrays.py index 167e74885b63..7f8c8d21013a 100644 --- a/ibis/backends/pandas/execution/arrays.py +++ b/ibis/backends/pandas/execution/arrays.py @@ -1,5 +1,6 @@ from __future__ import annotations +import itertools import operator from functools import partial from typing import TYPE_CHECKING, Any @@ -147,3 +148,10 @@ def execute_array_collect_groupby(op, data, where, aggcontext=None, **kwargs): @execute_node.register(ops.Unnest, pd.Series) def execute_unnest(op, data, **kwargs): return data.explode() + + +@execute_node.register(ops.ArrayFlatten, pd.Series) +def execute_array_flatten(op, data, **kwargs): + return data.map( + lambda v: list(itertools.chain.from_iterable(v)), na_action="ignore" + )