-  
-   Notifications  You must be signed in to change notification settings 
- Fork 19.2k
pivot_table very slow on Categorical data; how about an observed keyword argument? #24923 #24953
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  
  jreback merged 35 commits into pandas-dev:master from benjaminr:feature/pivot_table_groupby_observed        Apr 26, 2019  
    Merged  
 Changes from all commits
 Commits 
  Show all changes 
  35 commits   Select commit Hold shift + click to select a range 
 d1554c2  Update to frame and pivot to accept observed kwarg to pass to groupby… 
  benjaminr 0662fa3  Addition of whatsnew entry. 
  benjaminr 6121313  Added change to pass observed fixture to pivot_table test, added chan… 
  benjaminr 9f93ab9  Added "an" to whatsnew and added example from original issue to the t… 
  benjaminr ebe5972  Removed unnecessary sentence. 
  benjaminr 416e9c8  Test separated into own test. Added issue comment. Updated df var nam… 
  benjaminr 5c62063  Addition of asv for pivot_table of categorical data with observed key… 
  benjaminr 8663be2  Resolve PEP8 issue. 
  benjaminr a1e3afe  Merge in master from upstream. 
  benjaminr 22637a3  Minor adjustment to asv entry. 
  benjaminr 088f277  Merge branch 'master' of github.com:pandas-dev/pandas into feature/pi… 
  benjaminr 672847b  Merge branch 'master' into PR_TOOL_MERGE_PR_24953 
  jreback d97a077  Merge branch 'master' of github.com:pandas-dev/pandas into feature/pi… 
  benjaminr 9de99fa  Merge branch 'master' of github.com:pandas-dev/pandas into feature/pi… 
  benjaminr 9a9569f  Merge branch 'master' of github.com:pandas-dev/pandas into feature/pi… 
  benjaminr c8e085d  Triggering CI tests. 
  benjaminr 2516386  Triggering CI tests - attempt 2. 
  benjaminr 0efeed8  Merge branch 'master' of github.com:pandas-dev/pandas into feature/pi… 
  benjaminr 13168d2  Merge branch 'master' of github.com:pandas-dev/pandas into feature/pi… 
  benjaminr 8518833  Merge branch 'master' of github.com:pandas-dev/pandas into feature/pi… 
  benjaminr 58a8f6e  Merge branch 'master' of github.com:pandas-dev/pandas into feature/pi… 
  benjaminr 12b8fac  Triggering CI. 
  benjaminr 09af30b  Addition of test to ensure observed pivots on categorial data are ind… 
  benjaminr 6df9e6d  Removal of test that is otherwise handled by asv. 
  benjaminr a23b5d0  Extra asv benchmark to see difference between pivots on categorical d… 
  benjaminr 8d50e85  Removal of import time. 
  benjaminr 3d39dff  Fix pep8 issue. 
  benjaminr ee696d9  Merge branch 'master' of github.com:pandas-dev/pandas into feature/pi… 
  12c0f82  Merge branch 'master' of github.com:pandas-dev/pandas into feature/pi… 
  f586e42  Manual merging of conflicts. 
  benjaminr cf7e8f5  Trailing whitespace fix. 
  benjaminr a3bcf1a  Setting categorical datatype after calc on expected. 
  benjaminr bb7cfef  Merge branch 'master' of github.com:pandas-dev/pandas into feature/pi… 
  benjaminr 5921646  Empty commit to trigger CI. 
  benjaminr 3c1720c  Merge branch 'master' of github.com:pandas-dev/pandas into feature/pi… 
  benjaminr File filter
Filter by extension
Conversations
 Failed to load comments.  
    Loading  
 Jump to
  Jump to file  
  Failed to load files.  
    Loading  
 Diff view
Diff view
There are no files selected for viewing
   This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters   
        This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters   
        This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters   
     | Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -5701,6 +5701,12 @@ def pivot(self, index=None, columns=None, values=None): | |
| margins_name : string, default 'All' | ||
| Name of the row / column that will contain the totals | ||
| when margins is True. | ||
| observed : boolean, default False | ||
| This only applies if any of the groupers are Categoricals. | ||
| If True: only show observed values for categorical groupers. | ||
| If False: show all values for categorical groupers. | ||
|  | ||
| .. versionchanged :: 0.25.0 | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. versionadded | ||
|  | ||
| Returns | ||
| ------- | ||
|  | @@ -5791,12 +5797,12 @@ def pivot(self, index=None, columns=None, values=None): | |
| @Appender(_shared_docs['pivot_table']) | ||
| def pivot_table(self, values=None, index=None, columns=None, | ||
| aggfunc='mean', fill_value=None, margins=False, | ||
| dropna=True, margins_name='All'): | ||
| dropna=True, margins_name='All', observed=False): | ||
| from pandas.core.reshape.pivot import pivot_table | ||
| return pivot_table(self, values=values, index=index, columns=columns, | ||
| aggfunc=aggfunc, fill_value=fill_value, | ||
| margins=margins, dropna=dropna, | ||
| margins_name=margins_name) | ||
| margins_name=margins_name, observed=observed) | ||
|  | ||
| def stack(self, level=-1, dropna=True): | ||
| """ | ||
|  | ||
   This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters   
        This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters   
      Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.    
 
Uh oh!
There was an error while loading. Please reload this page.