Hello guys, I'm trying to map over pandas datafram...
# prefect-community
j
Hello guys, I'm trying to map over pandas dataframe groups, but I can't quite get it to work even though I am able to iterate over it in a python for-loop just fine. This is what I'm trying to do:
some_task.map(df.groupby("id"))
But it gives me:
KeyError: 'Column not found: 0'
Does anyone know if mapping over groups is supported and if yes, how? Thanks in advance
c
Hi Jonas, mapping over pandas dataframes is not currently supported - mapped objects must be list-like (e.g., indexed by position); if you can convert your groupby object into a list then you should be good!
👍 1
j
Amazing, works like a charm. Thank you very much!
e
^, use
list(df.groupby("id"))
instead. Even better, have a task return
list(df.groupby("id"))
, and map over the output of said task.