Skip to content

BUG: Resample.aggregate raising TypeError instead of SpecificationError with missing keys dtypes #39028

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 11 commits into from
Jan 8, 2021

Conversation

phofl
Copy link
Member

@phofl phofl commented Jan 7, 2021

@phofl phofl added the Resample resample method label Jan 7, 2021
@@ -738,7 +738,10 @@ def agg_dict_like(
if isinstance(selected_obj, ABCDataFrame) and len(
selected_obj.columns.intersection(keys)
) != len(keys):
cols = sorted(set(keys) - set(selected_obj.columns.intersection(keys)))
cols = sorted(
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 just use safe_sort?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, of course. Thx. Forgot about safe sort...

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm had to add list calls

@simonjayhawkins
Copy link
Member

simonjayhawkins commented Jan 8, 2021

Thanks @phofl for the PR. There is a very similar issue pandas/core/aggregation.py:485: error: Value of type variable "_LT" of "sorted" cannot be "Optional[Hashable]" [type-var] that I didn't yet add an issue for.

There are many tests that go through that path that could be used as the basis for a test for a fix.

=============================================== short test summary info ================================================
FAILED pandas/tests/base/test_misc.py::test_memory_usage[series-with-empty-index] - assert 0 == 108
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_listlike[axis 0-ops0-names0] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_listlike[axis 0-ops1-names1] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_listlike[axis 0-ops2-names2] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_listlike[axis 0-ops3-names3] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_listlike[axis 1-ops0-names0] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_listlike[axis 1-ops1-names1] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_listlike[axis 1-ops2-names2] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_listlike[axis 1-ops3-names3] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_listlike[axis 'index'-ops0-names0] - Assertio...
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_listlike[axis 'index'-ops1-names1] - Assertio...
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_listlike[axis 'index'-ops2-names2] - Assertio...
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_listlike[axis 'index'-ops3-names3] - Assertio...
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_listlike[axis 'columns'-ops0-names0] - Assert...
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_listlike[axis 'columns'-ops1-names1] - Assert...
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_listlike[axis 'columns'-ops2-names2] - Assert...
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_listlike[axis 'columns'-ops3-names3] - Assert...
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_empty_listlike[DataFrame-ops0] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_empty_listlike[DataFrame-ops1] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_dictlike[axis 0-dict] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_dictlike[axis 0-Series] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_dictlike[axis 1-dict] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_dictlike[axis 1-Series] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_dictlike[axis 'index'-dict] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_dictlike[axis 'index'-Series] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_dictlike[axis 'columns'-dict] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_dictlike[axis 'columns'-Series] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_empty_dictlike[DataFrame-ops1] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_empty_dictlike[DataFrame-ops2] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_empty_dictlike[DataFrame-ops3] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_empty_dictlike[DataFrame-ops4] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_empty_dictlike[DataFrame-ops5] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_and_agg_err[axis 0] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_and_agg_err[axis 1] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_and_agg_err[axis 'index'] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_and_agg_err[axis 'columns'] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_agg_dict_nested_renaming_depr - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_reducer_raises[sum-DataFrame] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_reducer_raises[max-DataFrame] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_reducer_raises[min-DataFrame] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_reducer_raises[mean-DataFrame] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_reducer_raises[prod-DataFrame] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_reducer_raises[std-DataFrame] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_reducer_raises[var-DataFrame] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_reducer_raises[median-DataFrame] - AssertionE...
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_reducer_raises[kurt-DataFrame] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_reducer_raises[skew-DataFrame] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_reducer_raises[all-DataFrame] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_reducer_raises[any-DataFrame] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_bad_dtype[DataFrame-cummax] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_bad_dtype[DataFrame-cummin] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_bad_dtype[DataFrame-cumprod] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_bad_dtype[DataFrame-cumsum] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_bad_dtype[DataFrame-diff] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_bad_dtype[DataFrame-pct_change] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_bad_dtype[DataFrame-rank] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_bad_dtype[DataFrame-<lambda>] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_partial_failure[cummax] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_partial_failure[cummin] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_partial_failure[cumprod] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_partial_failure[cumsum] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_partial_failure[diff] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_partial_failure[pct_change] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_partial_failure[rank] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_missing_columns[axis 0] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_missing_columns[axis 1] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_missing_columns[axis 'index'] - AssertionError
FAILED pandas/tests/frame/apply/test_frame_transform.py::test_transform_missing_columns[axis 'columns'] - AssertionError
FAILED pandas/tests/series/apply/test_series_transform.py::test_transform_none_to_type - AssertionError

AssertionError due to assert False added to code

so could either fix here, or shall I create a dedicated bug report?

update: ignore FAILED pandas/tests/base/test_misc.py::test_memory_usage[series-with-empty-index] - assert 0 == 108 as unrelated. (maybe WSL issue, not yet investigated)

@phofl
Copy link
Member Author

phofl commented Jan 8, 2021

I could look into this in the evening, when this pr is not merged until then we could do this here

@phofl
Copy link
Member Author

phofl commented Jan 8, 2021

@simonjayhawkins Fixed it.

I am not quite sure why the test was where it was, so I moved it into the frame folder.

@jreback jreback added this to the 1.3 milestone Jan 8, 2021
@jreback jreback added the Error Reporting Incorrect or improved errors from pandas label Jan 8, 2021
@jreback
Copy link
Contributor

jreback commented Jan 8, 2021

i know we marked the issues as a regression but that was from 1.0.x, so 1.3 is fine.

@phofl
Copy link
Member Author

phofl commented Jan 8, 2021

Thought the same, since only the message is the problem

@jreback jreback merged commit 8fe3dc6 into pandas-dev:master Jan 8, 2021
@jreback
Copy link
Contributor

jreback commented Jan 8, 2021

thanks @phofl

@phofl phofl deleted the 39025 branch January 8, 2021 23:18
luckyvs1 pushed a commit to luckyvs1/pandas that referenced this pull request Jan 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas Resample resample method
Projects
None yet
3 participants