Skip to content
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

ENH GH20601 raise error when pivot table's number of levels > int32 #20709

Closed
wants to merge 34 commits into from
Closed

ENH GH20601 raise error when pivot table's number of levels > int32 #20709

wants to merge 34 commits into from

Conversation

anhqle
Copy link

@anhqle anhqle commented Apr 16, 2018

What's New: Raise an error when the number of levels in a pivot table is larger than int32

@pep8speaks
Copy link

pep8speaks commented Apr 16, 2018

Hello @anhqle! Thanks for updating the PR.

Cheers ! There are no PEP8 issues in this Pull Request. 🍻

Comment last updated on April 16, 2018 at 06:07 Hours UTC

@gfyoung gfyoung added Error Reporting Incorrect or improved errors from pandas Numeric Operations Arithmetic, Comparison, and Logical operations Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff labels Apr 16, 2018
@gfyoung
Copy link
Member

gfyoung commented Apr 16, 2018

@anhqle : So far so good, but you're missing a whatsnew entry here.

@@ -162,6 +162,8 @@ def _make_selectors(self):
self.full_shape = ngroups, stride

selector = self.sorted_labels[-1] + stride * comp_index + self.lift
if np.prod(self.full_shape) > (2 ** 31 - 1):
raise ValueError('Pivot table is too big, causing int32 overflow')
Copy link
Member

Choose a reason for hiding this comment

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

@jreback : Is it okay to catch it here, or should we try to catch earlier as you mentioned before?

Copy link
Author

Choose a reason for hiding this comment

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

I'm happy to make any change, and would love to hear the reasoning for catching it earlier.

Copy link
Contributor

Choose a reason for hiding this comment

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

ideally as soon as you know this is out of bounds you want to raise.

@codecov
Copy link

codecov bot commented Apr 16, 2018

Codecov Report

Merging #20709 into master will decrease coverage by <.01%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #20709      +/-   ##
==========================================
- Coverage   91.84%   91.84%   -0.01%     
==========================================
  Files         153      153              
  Lines       49279    49281       +2     
==========================================
+ Hits        45259    45260       +1     
- Misses       4020     4021       +1
Flag Coverage Δ
#multiple 90.22% <50%> (-0.01%) ⬇️
#single 41.9% <0%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/reshape/reshape.py 99.78% <50%> (-0.22%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d04b746...2416db1. Read the comment docs.

xfail problematic s3 / moto tests
@pytest.mark.slow
def test_pivot_number_of_levels_larger_than_int32(self):
# GH 20601
data = DataFrame({'ind1': list(range(1337600)) * 2,
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of using list(range use np.arange (and array ops)

@@ -162,6 +162,8 @@ def _make_selectors(self):
self.full_shape = ngroups, stride

selector = self.sorted_labels[-1] + stride * comp_index + self.lift
if np.prod(self.full_shape) > (2 ** 31 - 1):
raise ValueError('Pivot table is too big, causing int32 overflow')
Copy link
Contributor

Choose a reason for hiding this comment

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

ideally as soon as you know this is out of bounds you want to raise.

@anhqle anhqle closed this Apr 22, 2018
@anhqle
Copy link
Author

anhqle commented Apr 22, 2018

I messed up git pull --rebase, opening a new PR #20784

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Error Reporting Incorrect or improved errors from pandas Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

Successfully merging this pull request may close these issues.