https://prefect.io logo
Title
a

Andy Dyer

05/05/2023, 8:03 PM
from prefect import Flow, flatten


files = preprocess_csv.map(flatten(list_of_csvs))
used to be this ^
d

Dominic Tarro

05/06/2023, 3:32 AM
@task
def flatten(nested: list[list]) -> list:
    return [el for arr in nested for el in arr]
f

flapili

05/06/2023, 11:56 AM
just use sum
nested = [list(range(5)) for x in range(5)]

nested
[[0, 1, 2, 3, 4], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4]]

sum(nested, [])
[0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4]