CLN: ASV groupby benchmarks
State: closed

- Ran flake8 and replaced star imports

- Moved `series_value_counts` to `series_methods.py`

- Used `params` with `param_names` and `setup_cache` where possible. 

```
asv dev -b ^groupby
[  0.00%] ··· Setting up /home/matt/Projects/pandas-mroeschke/asv_bench/benchmarks/groupby.py:267
[  1.19%] ··· Running groupby.AggBuiltins.time_agg_builtin_single_col                                       23.5ms
[  2.38%] ··· Running groupby.AggBuiltins.time_agg_builtins_multi_col                                       74.4ms
[  2.38%] ··· Setting up /home/matt/Projects/pandas-mroeschke/asv_bench/benchmarks/groupby.py:222
[  3.57%] ··· Running groupby.CountInt.time_int_count                                                       6.13ms
[  4.76%] ··· Running groupby.CountInt.time_int_nunique                                                     16.1ms
[  4.76%] ··· Setting up /home/matt/Projects/pandas-mroeschke/asv_bench/benchmarks/groupby.py:241
[  5.95%] ··· Running groupby.AggMultiColFuncs.time_different_numpy_functions                               22.3ms
[  7.14%] ··· Running groupby.AggMultiColFuncs.time_different_str_functions                                 22.2ms
[  7.14%] ··· Setting up /home/matt/Projects/pandas-mroeschke/asv_bench/benchmarks/groupby.py:142
[  8.33%] ··· Running groupby.Nth.time_frame_nth                                                            4.66ms
[  9.52%] ··· Running groupby.Nth.time_frame_nth_any                                                        11.1ms
[ 10.71%] ··· Running groupby.Nth.time_series_nth                                                           7.77ms
[ 11.90%] ··· Running groupby.Nth.time_series_nth_any                                                       15.5ms
[ 13.10%] ··· Running groupby.Apply.time_copy_function_multi_col                                             3.08s
[ 14.29%] ··· Running groupby.Apply.time_copy_overhead_single_col                                            1.20s
[ 15.48%] ··· Running groupby.Apply.time_scalar_function_multi_col                                          70.6ms
[ 16.67%] ··· Running groupby.Apply.time_scalar_function_single_col                                         13.4ms
[ 17.86%] ··· Running groupby.ApplyDictReturn.time_groupby_apply_dict_return                                92.7ms
[ 19.05%] ··· Running groupby.Categories.time_groupby_extra_cat_nosort                                      20.1ms
[ 20.24%] ··· Running groupby.Categories.time_groupby_extra_cat_sort                                        4.14ms
[ 21.43%] ··· Running groupby.Categories.time_groupby_nosort                                                23.3ms
[ 22.62%] ··· Running groupby.Categories.time_groupby_ordered_nosort                                        33.0ms
[ 23.81%] ··· Running groupby.Categories.time_groupby_ordered_sort                                          4.65ms
[ 25.00%] ··· Running groupby.Categories.time_groupby_sort                                                  4.58ms
[ 26.19%] ··· Running groupby.CountMultiDtype.time_multi_count                                              9.43ms
[ 27.38%] ··· Running groupby.Datelike.time_sum                                                                 ok
[ 27.38%] ···· 
               ============================================== ========
                                  grouper                             
               ---------------------------------------------- --------
                 <function period_range at 0x7f68a63f75f0>     64.0ms 
                  <function date_range at 0x7f68a63f22a8>      5.11ms 
                <functools.partial object at 0x7f68a09aba48>   7.83ms 
               ============================================== ========

[ 28.57%] ··· Running groupby.FirstLast.time_groupby_first                                                      ok
[ 28.57%] ···· 
               ========== ========
                 dtype            
               ---------- --------
                float32    9.26ms 
                float64    9.12ms 
                datetime   20.3ms 
                 object    29.8ms 
               ========== ========

[ 29.76%] ··· Running groupby.FirstLast.time_groupby_last                                                       ok
[ 29.76%] ···· 
               ========== ========
                 dtype            
               ---------- --------
                float32    9.40ms 
                float64    8.81ms 
                datetime   20.3ms 
                 object    26.8ms 
               ========== ========

[ 30.95%] ··· Running groupby.FirstLast.time_groupby_nth_all                                                    ok
[ 30.95%] ···· 
               ========== ========
                 dtype            
               ---------- --------
                float32    53.6ms 
                float64    55.3ms 
                datetime   78.5ms 
                 object    88.9ms 
               ========== ========

[ 32.14%] ··· Running groupby.FirstLast.time_groupby_nth_none                                                   ok
[ 32.14%] ···· 
               ========== ========
                 dtype            
               ---------- --------
                float32    27.8ms 
                float64    27.6ms 
                datetime   41.4ms 
                 object    44.8ms 
               ========== ========

[ 33.33%] ··· Running groupby.Float32.time_sum                                                              15.8ms
[ 34.52%] ··· Running groupby.GroupByMethods.time_all                                                           ok
[ 34.52%] ···· 
               ======= ======== =======
               --          ngroups     
               ------- ----------------
                dtype    100     10000 
               ======= ======== =======
                 int    27.6ms   2.52s 
                float   42.0ms   4.03s 
               ======= ======== =======

[ 35.71%] ··· Running groupby.GroupByMethods.time_any                                                           ok
[ 35.71%] ···· 
               ======= ======== =======
               --          ngroups     
               ------- ----------------
                dtype    100     10000 
               ======= ======== =======
                 int    27.5ms   2.55s 
                float   42.7ms   4.05s 
               ======= ======== =======

[ 36.90%] ··· Running groupby.GroupByMethods.time_count                                                         ok
[ 36.90%] ···· 
               ======= ======== ========
               --           ngroups     
               ------- -----------------
                dtype    100     10000  
               ======= ======== ========
                 int    1.03ms   3.93ms 
                float   1.09ms   5.49ms 
               ======= ======== ========

[ 38.10%] ··· Running groupby.GroupByMethods.time_cumcount                                                      ok
[ 38.10%] ···· 
               ======= ======== ========
               --           ngroups     
               ------- -----------------
                dtype    100     10000  
               ======= ======== ========
                 int    1.23ms   5.41ms 
                float   1.24ms   6.52ms 
               ======= ======== ========

[ 39.29%] ··· Running groupby.GroupByMethods.time_cummax                                                        ok
[ 39.29%] ···· 
               ======= ======== ========
               --           ngroups     
               ------- -----------------
                dtype    100     10000  
               ======= ======== ========
                 int    1.22ms   4.28ms 
                float   1.27ms   5.63ms 
               ======= ======== ========

[ 40.48%] ··· Running groupby.GroupByMethods.time_cummin                                                        ok
[ 40.48%] ···· 
               ======= ======== ========
               --           ngroups     
               ------- -----------------
                dtype    100     10000  
               ======= ======== ========
                 int    1.21ms   4.28ms 
                float   1.32ms   5.74ms 
               ======= ======== ========

[ 41.67%] ··· Running groupby.GroupByMethods.time_cumprod                                                       ok
[ 41.67%] ···· 
               ======= ======== ========
               --           ngroups     
               ------- -----------------
                dtype    100     10000  
               ======= ======== ========
                 int    1.60ms   5.12ms 
                float   1.67ms   6.47ms 
               ======= ======== ========

[ 42.86%] ··· Running groupby.GroupByMethods.time_cumsum                                                        ok
[ 42.86%] ···· 
               ======= ======== ========
               --           ngroups     
               ------- -----------------
                dtype    100     10000  
               ======= ======== ========
                 int    1.29ms   4.26ms 
                float   1.34ms   5.62ms 
               ======= ======== ========

[ 44.05%] ··· Running groupby.GroupByMethods.time_describe                                                      ok
[ 44.05%] ···· 
               ======= ======= =======
               --          ngroups    
               ------- ---------------
                dtype    100    10000 
               ======= ======= =======
                 int    296ms   28.8s 
                float   465ms   45.9s 
               ======= ======= =======

[ 45.24%] ··· Running groupby.GroupByMethods.time_diff                                                          ok
[ 45.24%] ···· 
               ======= ======== =======
               --          ngroups     
               ------- ----------------
                dtype    100     10000 
               ======= ======== =======
                 int    37.6ms   3.47s 
                float   57.0ms   5.50s 
               ======= ======== =======

[ 46.43%] ··· Running groupby.GroupByMethods.time_first                                                         ok
[ 46.43%] ···· 
               ======= ======== ========
               --           ngroups     
               ------- -----------------
                dtype    100     10000  
               ======= ======== ========
                 int    1.19ms   4.45ms 
                float   1.27ms   5.98ms 
               ======= ======== ========

[ 47.62%] ··· Running groupby.GroupByMethods.time_head                                                          ok
[ 47.62%] ···· 
               ======= ======== ========
               --           ngroups     
               ------- -----------------
                dtype    100     10000  
               ======= ======== ========
                 int    1.72ms   5.90ms 
                float   1.77ms   7.32ms 
               ======= ======== ========

[ 48.81%] ··· Running groupby.GroupByMethods.time_last                                                          ok
[ 48.81%] ···· 
               ======= ======== ========
               --           ngroups     
               ------- -----------------
                dtype    100     10000  
               ======= ======== ========
                 int    1.18ms   4.27ms 
                float   1.26ms   5.89ms 
               ======= ======== ========

[ 50.00%] ··· Running groupby.GroupByMethods.time_mad                                                           ok
[ 50.00%] ···· 
               ======= ======= =======
               --          ngroups    
               ------- ---------------
                dtype    100    10000 
               ======= ======= =======
                 int    104ms   9.95s 
                float   157ms   15.6s 
               ======= ======= =======

[ 51.19%] ··· Running groupby.GroupByMethods.time_max                                                           ok
[ 51.19%] ···· 
               ======= ======== ========
               --           ngroups     
               ------- -----------------
                dtype    100     10000  
               ======= ======== ========
                 int    1.44ms   4.39ms 
                float   1.34ms   5.98ms 
               ======= ======== ========

[ 52.38%] ··· Running groupby.GroupByMethods.time_mean                                                          ok
[ 52.38%] ···· 
               ======= ======== ========
               --           ngroups     
               ------- -----------------
                dtype    100     10000  
               ======= ======== ========
                 int    1.39ms   4.64ms 
                float   1.71ms   6.86ms 
               ======= ======== ========

[ 53.57%] ··· Running groupby.GroupByMethods.time_median                                                        ok
[ 53.57%] ···· 
               ======= ======== ========
               --           ngroups     
               ------- -----------------
                dtype    100     10000  
               ======= ======== ========
                 int    1.39ms   5.81ms 
                float   1.66ms   7.52ms 
               ======= ======== ========

[ 54.76%] ··· Running groupby.GroupByMethods.time_min                                                           ok
[ 54.76%] ···· 
               ======= ======== ========
               --           ngroups     
               ------- -----------------
                dtype    100     10000  
               ======= ======== ========
                 int    1.21ms   4.54ms 
                float   1.26ms   5.99ms 
               ======= ======== ========

[ 55.95%] ··· Running groupby.GroupByMethods.time_nunique                                                       ok
[ 55.95%] ···· 
               ======= ======== ========
               --           ngroups     
               ------- -----------------
                dtype    100     10000  
               ======= ======== ========
                 int    1.17ms   8.68ms 
                float   1.20ms   10.2ms 
               ======= ======== ========

[ 57.14%] ··· Running groupby.GroupByMethods.time_pct_change                                                    ok
[ 57.14%] ···· 
               ======= ======= =======
               --          ngroups    
               ------- ---------------
                dtype    100    10000 
               ======= ======= =======
                 int    118ms   11.4s 
                float   181ms   17.8s 
               ======= ======= =======

[ 58.33%] ··· Running groupby.GroupByMethods.time_prod                                                          ok
[ 58.33%] ···· 
               ======= ======== ========
               --           ngroups     
               ------- -----------------
                dtype    100     10000  
               ======= ======== ========
                 int    1.60ms   4.90ms 
                float   1.61ms   6.78ms 
               ======= ======== ========

[ 59.52%] ··· Running groupby.GroupByMethods.time_rank                                                          ok
[ 59.52%] ···· 
               ======= ======== =======
               --          ngroups     
               ------- ----------------
                dtype    100     10000 
               ======= ======== =======
                 int    42.1ms   3.95s 
                float   64.3ms   6.24s 
               ======= ======== =======

[ 60.71%] ··· Running groupby.GroupByMethods.time_sem                                                           ok
[ 60.71%] ···· 
               ======= ======== ========
               --           ngroups     
               ------- -----------------
                dtype    100     10000  
               ======= ======== ========
                 int    2.05ms   6.39ms 
                float   2.01ms   7.83ms 
               ======= ======== ========

[ 61.90%] ··· Running groupby.GroupByMethods.time_shift                                                         ok
[ 61.90%] ···· 
               ======= ======== ========
               --           ngroups     
               ------- -----------------
                dtype    100     10000  
               ======= ======== ========
                 int    1.03ms   4.64ms 
                float   1.08ms   5.89ms 
               ======= ======== ========

[ 63.10%] ··· Running groupby.GroupByMethods.time_size                                                          ok
[ 63.10%] ···· 
               ======= ======== ========
               --           ngroups     
               ------- -----------------
                dtype    100     10000  
               ======= ======== ========
                 int    978μs    3.80ms 
                float   1.06ms   5.38ms 
               ======= ======== ========

[ 64.29%] ··· Running groupby.GroupByMethods.time_skew                                                          ok
[ 64.29%] ···· 
               ======= ======== =======
               --          ngroups     
               ------- ----------------
                dtype    100     10000 
               ======= ======== =======
                 int    43.3ms   4.13s 
                float   66.6ms   6.52s 
               ======= ======== =======

[ 65.48%] ··· Running groupby.GroupByMethods.time_std                                                           ok
[ 65.48%] ···· 
               ======= ======== ========
               --           ngroups     
               ------- -----------------
                dtype    100     10000  
               ======= ======== ========
                 int    1.51ms   5.04ms 
                float   1.51ms   6.62ms 
               ======= ======== ========

[ 66.67%] ··· Running groupby.GroupByMethods.time_sum                                                           ok
[ 66.67%] ···· 
               ======= ======== ========
               --           ngroups     
               ------- -----------------
                dtype    100     10000  
               ======= ======== ========
                 int    1.89ms   4.99ms 
                float   1.66ms   6.69ms 
               ======= ======== ========

[ 67.86%] ··· Running groupby.GroupByMethods.time_tail                                                          ok
[ 67.86%] ···· 
               ======= ======== ========
               --           ngroups     
               ------- -----------------
                dtype    100     10000  
               ======= ======== ========
                 int    1.71ms   5.97ms 
                float   1.76ms   7.05ms 
               ======= ======== ========

[ 69.05%] ··· Running groupby.GroupByMethods.time_unique                                                        ok
[ 69.05%] ···· 
               ======= ======== =======
               --          ngroups     
               ------- ----------------
                dtype    100     10000 
               ======= ======== =======
                 int    26.3ms   2.37s 
                float   40.3ms   3.77s 
               ======= ======== =======

[ 70.24%] ··· Running groupby.GroupByMethods.time_value_counts                                                  ok
[ 70.24%] ···· 
               ======= ======== ========
               --           ngroups     
               ------- -----------------
                dtype    100     10000  
               ======= ======== ========
                 int    1.75ms   13.6ms 
                float   1.81ms   15.3ms 
               ======= ======== ========

[ 71.43%] ··· Running groupby.GroupByMethods.time_var                                                           ok
[ 71.43%] ···· 
               ======= ======== ========
               --           ngroups     
               ------- -----------------
                dtype    100     10000  
               ======= ======== ========
                 int    1.35ms   4.85ms 
                float   1.38ms   6.25ms 
               ======= ======== ========

[ 72.62%] ··· Running groupby.GroupManyLabels.time_sum                                                          ok
[ 72.62%] ···· 
               ======= ========
                ncols          
               ------- --------
                  1     6.72ms 
                 1000   14.2ms 
               ======= ========

[ 73.81%] ··· Running groupby.GroupStrings.time_multi_columns                                                1.28s
[ 75.00%] ··· Running groupby.Groups.time_series_groups                                                         ok
[ 75.00%] ···· 
               ============== ========
                    ser               
               -------------- --------
                int64_small    90.4ms 
                int64_large    320ms  
                object_small   140ms  
                object_large   457ms  
               ============== ========

[ 76.19%] ··· Running groupby.Incidies.time_datetime_indicies                                               11.3ms
[ 77.38%] ··· Running groupby.Int64.time_overflow                                                            615ms
[ 78.57%] ··· Running groupby.MultiColumn.time_col_select_lambda_sum                                         252ms
[ 79.76%] ··· Running groupby.MultiColumn.time_col_select_numpy_sum                                         24.7ms
[ 80.95%] ··· Running groupby.MultiColumn.time_cython_sum                                                   29.0ms
[ 82.14%] ··· Running groupby.MultiColumn.time_lambda_sum                                                    496ms
[ 83.33%] ··· Running groupby.PivotTable.time_pivot_table                                                   37.2ms
[ 84.52%] ··· Running groupby.Size.time_category_size                                                       13.1ms
[ 85.71%] ··· Running groupby.Size.time_dt_size                                                             19.5ms
[ 86.90%] ··· Running groupby.Size.time_dt_timegrouper_size                                                 51.4ms
[ 88.10%] ··· Running groupby.Size.time_multi_size                                                          25.5ms
[ 89.29%] ··· Running groupby.SumBools.time_groupby_sum_booleans                                            3.22ms
[ 90.48%] ··· Running groupby.SumMultiLevel.time_groupby_sum_multiindex                                     2.65ms
[ 91.67%] ··· Running groupby.Transform.time_transform_lambda_max                                            735ms
[ 92.86%] ··· Running groupby.Transform.time_transform_multi_key1                                           15.9ms
[ 94.05%] ··· Running groupby.Transform.time_transform_multi_key2                                           13.5ms
[ 95.24%] ··· Running groupby.Transform.time_transform_multi_key3                                           12.6ms
[ 96.43%] ··· Running groupby.Transform.time_transform_multi_key4                                           6.76ms
[ 97.62%] ··· Running groupby.Transform.time_transform_ufunc_max                                            13.8ms
[ 98.81%] ··· Running groupby.TransformBools.time_transform_mean                                            8.44ms
[100.00%] ··· Running groupby.TransformNaN.time_first                                                       5.82ms
```


Labels:
name: Benchmark
description: Performance (ASV) benchmarks

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18611?src=pr&el=h1) Report
> Merging [#18611](https://codecov.io/gh/pandas-dev/pandas/pull/18611?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/bd9a3e06621e0b2bff3a7f4a6bf68c886b0db4c3?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/18611/graphs/tree.svg?height=150&width=650&token=eZ4WkYLtcO&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/18611?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #18611      +/-   ##
==========================================
+ Coverage   91.44%   91.45%   +<.01%     
==========================================
  Files         157      157              
  Lines       51449    51449              
==========================================
+ Hits        47048    47051       +3     
+ Misses       4401     4398       -3
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.32% <ø> (+0.02%)` | :arrow_up: |
| #single | `40.6% <ø> (-0.11%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/18611?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/18611/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/18611/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.81% <0%> (-0.1%)` | :arrow_down: |
| [pandas/plotting/\_converter.py](https://codecov.io/gh/pandas-dev/pandas/pull/18611/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb252ZXJ0ZXIucHk=) | `65.25% <0%> (+1.81%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18611?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18611?src=pr&el=footer). Last update [bd9a3e0...d935a37](https://codecov.io/gh/pandas-dev/pandas/pull/18611?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18611?src=pr&el=h1) Report
> Merging [#18611](https://codecov.io/gh/pandas-dev/pandas/pull/18611?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/52fefd50f8bffa493018ba8ff8b8c46b95c94ada?src=pr&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/18611/graphs/tree.svg?token=eZ4WkYLtcO&width=650&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/18611?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #18611      +/-   ##
==========================================
- Coverage    91.6%   91.58%   -0.02%     
==========================================
  Files         153      153              
  Lines       51253    51253              
==========================================
- Hits        46950    46941       -9     
- Misses       4303     4312       +9
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.45% <ø> (ø)` | :arrow_up: |
| #single | `40.67% <ø> (-0.11%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/18611?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/18611/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/18611/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.81% <0%> (-0.1%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18611?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18611?src=pr&el=footer). Last update [52fefd5...b81baf5](https://codecov.io/gh/pandas-dev/pandas/pull/18611?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

Good catch @jreback. I was able to use `setup_cache` there
Thanks for the review @jorisvandenbossche, addressed your comments. 
Thanks!