@@ -3221,10 +3221,67 @@ def test_groupby_whitelist(self):
32213221 'letters' : Series (random_letters )})
32223222 s = df .floats
32233223
3224- blacklist = ['eval' , 'query' , 'abs' , 'shift' , 'tshift' , 'where' ,
3225- 'mask' , 'align' , 'groupby' , 'clip' , 'astype' ,
3226- 'at' , 'combine' , 'consolidate' , 'convert_objects' ,
3227- 'corr' , 'corr_with' , 'cov' ]
3224+ df_whitelist = frozenset ([
3225+ 'last' , 'first' ,
3226+ 'mean' , 'sum' , 'min' , 'max' ,
3227+ 'head' , 'tail' ,
3228+ 'cumsum' , 'cumprod' , 'cummin' , 'cummax' , 'cumcount' ,
3229+ 'resample' ,
3230+ 'describe' ,
3231+ 'rank' , 'quantile' , 'count' ,
3232+ 'fillna' ,
3233+ 'mad' ,
3234+ 'any' , 'all' ,
3235+ 'irow' , 'take' ,
3236+ 'shift' , 'tshift' ,
3237+ 'ffill' , 'bfill' ,
3238+ 'pct_change' , 'skew' ,
3239+ 'plot' , 'boxplot' , 'hist' ,
3240+ 'median' , 'dtypes' ,
3241+ 'corrwith' , 'corr' , 'cov' ,
3242+ ])
3243+ s_whitelist = frozenset ([
3244+ 'last' , 'first' ,
3245+ 'mean' , 'sum' , 'min' , 'max' ,
3246+ 'head' , 'tail' ,
3247+ 'cumsum' , 'cumprod' , 'cummin' , 'cummax' , 'cumcount' ,
3248+ 'resample' ,
3249+ 'describe' ,
3250+ 'rank' , 'quantile' , 'count' ,
3251+ 'fillna' ,
3252+ 'mad' ,
3253+ 'any' , 'all' ,
3254+ 'irow' , 'take' ,
3255+ 'shift' , 'tshift' ,
3256+ 'ffill' , 'bfill' ,
3257+ 'pct_change' , 'skew' ,
3258+ 'plot' , 'hist' ,
3259+ 'median' , 'dtype' ,
3260+ 'corr' , 'cov' ,
3261+ 'value_counts' ,
3262+ ])
3263+
3264+ for obj , whitelist in zip ((df , s ),
3265+ (df_whitelist , s_whitelist )):
3266+ gb = obj .groupby (df .letters )
3267+ self .assertEqual (whitelist , gb ._apply_whitelist )
3268+ for m in whitelist :
3269+ getattr (gb , m )
3270+
3271+ def test_groupby_blacklist (self ):
3272+ from string import ascii_lowercase
3273+ letters = np .array (list (ascii_lowercase ))
3274+ N = 10
3275+ random_letters = letters .take (np .random .randint (0 , 26 , N ))
3276+ df = DataFrame ({'floats' : N / 10 * Series (np .random .random (N )),
3277+ 'letters' : Series (random_letters )})
3278+ s = df .floats
3279+
3280+ blacklist = [
3281+ 'eval' , 'query' , 'abs' , 'where' ,
3282+ 'mask' , 'align' , 'groupby' , 'clip' , 'astype' ,
3283+ 'at' , 'combine' , 'consolidate' , 'convert_objects' ,
3284+ ]
32283285 to_methods = [method for method in dir (df ) if method .startswith ('to_' )]
32293286
32303287 blacklist .extend (to_methods )
@@ -3319,8 +3376,12 @@ def test_tab_completion(self):
33193376 'groups' ,'hist' ,'indices' ,'last' ,'max' ,'mean' ,'median' ,
33203377 'min' ,'name' ,'ngroups' ,'nth' ,'ohlc' ,'plot' , 'prod' ,
33213378 'size' ,'std' ,'sum' ,'transform' ,'var' , 'count' , 'head' , 'describe' ,
3322- 'cummax' , 'dtype' , 'quantile' , 'rank' , 'cumprod' , 'tail' ,
3323- 'resample' , 'cummin' , 'fillna' , 'cumsum' , 'cumcount' ])
3379+ 'cummax' , 'quantile' , 'rank' , 'cumprod' , 'tail' ,
3380+ 'resample' , 'cummin' , 'fillna' , 'cumsum' , 'cumcount' ,
3381+ 'all' , 'shift' , 'skew' , 'bfill' , 'irow' , 'ffill' ,
3382+ 'take' , 'tshift' , 'pct_change' , 'any' , 'mad' , 'corr' , 'corrwith' ,
3383+ 'cov' , 'dtypes' ,
3384+ ])
33243385 self .assertEqual (results , expected )
33253386
33263387def assert_fp_equal (a , b ):
0 commit comments