Hey all :slightly_smiling_face: We got the follow...
# prefect-community
Hey all ūüôā We got the following error when trying to map over a list of dictionaries. First just to clarify: mapping over a list of dictionaries should be fine, right? Second, what could be the reason for the message?
‚úĒÔłŹ 1
Hi Robin, mapping over a list of dictionaries should be fine. The error you're getting here is happening in your task here (the actual mapping appears to be working correctly) - looks like you're getting a list where you expected a dict - perhaps you're passing in a list of lists instead?
Good point! Thanks for the quick feedback ūüôā
In that case, this should work, right?
Copy code
reduce_list = task(lambda list_of_lists: reduce(list.extend, list_of_lists, []))
Copy code
def reduce_list(list_of_lists):
    out = []
    for l in list_of_lists:
    return out
did the trick ūüôā
That'd work, you could also make use of the new(ish)
, which will do that for you (but potentially in a more efficient way).
Copy code
See https://docs.prefect.io/core/concepts/mapping.html#flat-mapping for more info.
Thanks for the tip! that looks neat ūüôā
@Severin Ryberg [sevberg]