Skip to content

ERR: Better error message for missing columns in aggregate #32836

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

Merged
merged 4 commits into from
Mar 22, 2020

Conversation

JDTruj2018
Copy link
Contributor

More descriptive SpecificationError message that reports to user non-existing columns causing error

… to user non-existing columns causing error

Line too long - corrected

What's New

Updated Tests

Fixed testing errors
@jreback jreback changed the title Issue 32755 Fix ERR: Better error message for missing columns in aggregate Mar 21, 2020
@jreback jreback added Apply Apply, Aggregate, Transform, Map Error Reporting Incorrect or improved errors from pandas labels Mar 21, 2020
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks fine, ping on green.

@@ -356,7 +356,11 @@ def _aggregate(self, arg, *args, **kwargs):
if isinstance(obj, ABCDataFrame) and len(
obj.columns.intersection(keys)
) != len(keys):
raise SpecificationError("nested renamer is not supported")
cols = sorted(set(keys) - set(obj.columns.intersection(keys)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its not worth it dispatching on both, just make. single message

@@ -84,7 +84,7 @@ Other API changes
- Added :meth:`DataFrame.value_counts` (:issue:`5377`)
- :meth:`Groupby.groups` now returns an abbreviated representation when called on large dataframes (:issue:`1135`)
- ``loc`` lookups with an object-dtype :class:`Index` and an integer key will now raise ``KeyError`` instead of ``TypeError`` when key is missing (:issue:`31905`)
-
- :meth:`DataFrame.agg` now provides more descriptive SpecificationError message when attempting to aggregating non-existant column (:issue:`32755`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move this to reshaping

@jreback
Copy link
Contributor

jreback commented Mar 21, 2020

merge master to fix the docs issue

@JDTruj2018
Copy link
Contributor Author

@jreback Made changes and green

@jreback jreback added this to the 1.1 milestone Mar 22, 2020
@jreback jreback merged commit 8f90046 into pandas-dev:master Mar 22, 2020
@jreback
Copy link
Contributor

jreback commented Mar 22, 2020

thanks @JDTruj2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Apply Apply, Aggregate, Transform, Map Error Reporting Incorrect or improved errors from pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Request: Better error message for missing columns in aggregate
2 participants