-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
REG: DataFrame/Series.transform with list and non-list dict values #40090
Conversation
doc/source/whatsnew/v1.3.0.rst
Outdated
@@ -327,6 +327,7 @@ Numeric | |||
- Bug in :func:`select_dtypes` different behavior between Windows and Linux with ``include="int"`` (:issue:`36569`) | |||
- Bug in :meth:`DataFrame.apply` and :meth:`DataFrame.agg` when passed argument ``func="size"`` would operate on the entire ``DataFrame`` instead of rows or columns (:issue:`39934`) | |||
- Bug in :meth:`DataFrame.transform` would raise ``SpecificationError`` when passed a dictionary and columns were missing; will now raise a ``KeyError`` instead (:issue:`40004`) | |||
- Bug in :meth:`DataFrame.transform` and :meth:`Series.transform` would have incorrect column labels when passed a dictionary with a mix of list and non-list values (:issue:`40018`) |
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.
can you put in 1.2.3
seems fine. can you merge master. and then can backport (agreed may require some work on that branch). |
|
||
Ensures that necessary columns exist if obj is a DataFrame, and | ||
that a nested renamer is not passed. | ||
that a nested renamer is not passed. Also normalizes to all lists |
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.
maybe not here if too many changes for a backport, but maybe change function name to say normalize_dictlike_arg
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.
@simonjayhawkins Thanks for the suggestion. That's actually how I started this out, but then changed it to validate recalling util._validators
(some of those do only validate, but a bunch also normalize). I'm seeing a mix of normalize or validate used. I'll change to normalize here, but maybe we should make this consistent.
Related: #19171
thanks @rhshadrach pls track the backport itself as it likely won't merge cleanly |
@meeseeksdev backport 1.2.x |
This comment has been minimized.
This comment has been minimized.
…st and non-list dict values
Currently on master,
agg
does some preprocessing on dict-like arguments thattransform
does not, leading to incorrect behavior intransform
. This PR movesagg
's preprocessing intovalidate_dictlike_arg
which is used by bothagg
andtransform
, fixing the issue.As identified in #40018, this is a regression from 1.1 -> 1.2 (almost certainly from one of my PRs, but I haven't checked which). Backporting this to 1.2 will probably require a bit of a different fix.