Expand groupby dispatch whitelist (GH5480) by gdraps · Pull Request #5604 · pandas-dev/pandas (original) (raw)

@jreback, a blacklist was created to block access to some methods while deprecating access to others (my interpretation of the comments in #5480). In summary, the changes in this PR are:

  1. add the following methods to the groupby whitelist:
'dtypes', 'value_counts', 'mad', 'any', 'all', 'irow', 'take', 'shift', 'tshift', 'ffill', 'bfill', 'pct_change', 'skew', 'corr', 'corrwith', 'cov'  
  1. create a blacklist to block access to:
    'eval', 'query', to_*
  2. change AttributeError to a DeprecationWarning when accessing methods not in either whitelist or blacklist

Re: testing, I added a new commit to this PR with improved whitelist testing (the full whitelist is hard-coded in the test suite now and compared to the defined whitelist). Since some methods in the whitelist are unique to Series or DataFrame, the whitelist needed to be refactored a bit, but that should clean up erroneous tab completion results (i.e., dtype on a DataFrameGroupBy object).

Let me know if I should back out changes 2 & 3, or if there are any other suggestions.