j

    Jonas Hanfland

    2 years ago
    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
    Chris White

    Chris White

    2 years ago
    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!
    j

    Jonas Hanfland

    2 years ago
    Amazing, works like a charm. Thank you very much!
    emre

    emre

    2 years ago
    ^, use
    list(df.groupby("id"))
    instead. Even better, have a task return
    list(df.groupby("id"))
    , and map over the output of said task.