-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
REF: document casting behavior in groupby #41376
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
Conversation
jbrockmendel
commented
May 8, 2021
- closes #xxxx
- tests added / passed
- Ensure all linting tests pass, see here for how to run them
- whatsnew entry
@@ -1236,12 +1233,11 @@ def _wrap_applied_output_series( | |||
columns = key_index | |||
stacked_values = stacked_values.T | |||
|
|||
if stacked_values.dtype == object: | |||
# We'll have the DataFrame constructor do inference | |||
stacked_values = stacked_values.tolist() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any perf impact by passing a list to DataFrame constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_apply_numeric_coercion_when_datetime goes through here. running the usage in timeit looks like a wash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we may be able to do better/cleaner following #40489
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also pls rebase
pandas/core/groupby/ops.py
Outdated
@@ -967,11 +967,22 @@ def _cython_operation( | |||
) | |||
|
|||
@final | |||
def agg_series(self, obj: Series, func: F) -> ArrayLike: | |||
def agg_series(self, obj: Series, func: F, preserve: bool = False) -> ArrayLike: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
preserve_dtype? I don't know if we use this keyword elsewhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or cast?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changing to preserve_dtype
and perf question |
updated + green |