-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
DOC: Dataframe.apply does not always return a Series when reduce=True #15628
Comments
please show a copy pastable example |
updated to copy pastable example |
The issue is returning lists from a function are subject to interpretation and thus a single element list is ambiguous. You can return a tuple instead which works unambiguously. Note that returning non-scalars is generally not recommended and is not efficiently supported.
closing as not a bug / won't fix. |
a bit more commentary in #14370 |
Thanks for the feedback. |
@jreback I agree that |
I guess the doc-string is misleading. I suppose some nice examples of what not to do in .apply (like returning a 1-element list and expecting it work, rather returning tuples) might be in order. @NelsonAndrew I'll re-open as a doc issue.
|
Code Sample, a copy-pastable example if possible
Problem description
Per the documentation, calling Dataframe.apply w/ reduce=True should always produce a Series. However, if the applied function returns list values Dataframe.apply returns a Dataframe, not a Series.
Expected Output
When called with reduce=True, I expect Dataframe.apply to produce a Series where each element is a list, not a Dataframe.
Output of
pd.show_versions()
0.18.1
The text was updated successfully, but these errors were encountered: