-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DataFrame.apply returns Series #389
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
It's kind of unclear what to do here-- should you pass an empty Series to the passed function to see if the function is a reduction or not? I literally just tinkered with this yesterday |
I think you'd pass an empty series to the function. What option would you favor? |
Seems like a reasonable route. Maybe should raise an exception if it can't figure things out |
Yeah, I haven't seen the underlying code. It just seems that if DataFrame.apply is called on an empty DataFrame and the lambda returns a Series when given an empty Series, the result should be an empty DataFrame. If the lambda returns a scalar, it would make sense the result is an empty Series. Unless I misunderstand apply. I know this is a pretty degenerate case... and we could work around it - but thanks for thinking about it! |
fixed this and added tests in the above commit |
Renaming libraries within a database/namespace
from pandas import DataFrame, DateRange
dr = DateRange('2011-11-01','2011-11-15')
df = DataFrame(index=dr)
df_or_so_youd_think = df.apply(lambda x:x)
print df_or_so_youd_think
This returns an empty Series.
The text was updated successfully, but these errors were encountered: