-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
GroupBy aggregate: Must produce aggregated value #24016
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you provide a minimal reproducible example and the output of |
I would say generally we don't really have first class support for doing this, as outside the confines of apply it would be ambiguous as to the desired shape of the returned function. What type would you be expecting besides object here? |
Thanks for you feedback: Example ('0.23.0'):
To give you some more background: |
Closing as I don't think this is something we really do or want to support. You'd be better off leveraging a MultiIndex to store your data rather than trying to place a NumPy array in a particular location of the frame |
I want to aggregate my dataframe by id and this is not the first time I came across this error, which is basically happening because it seems not to be allowed to return a numpy array in the aggregation function.
There are dozens of use cases, where rows are aggregated to numpy arrays and wrapping it with a list does lead to several other problems, like the datatype of the hole dataframe is of type “object” after transformation, even if every column had the same type. When feeding such a dataframe into keras it is a mess to get the data into the correct format.
When using
list()
as a wrapper it works but it would be more comfortable to just use the numpy array without having to unwrap the list.Related code:
generic.py[908]
Maybe anyone has another idea to get over this issue?
The text was updated successfully, but these errors were encountered: