kieferk / dfply

dplyr-style piping operations for pandas dataframes
GNU General Public License v3.0
889 stars 103 forks source link

group_by fails to raise exception for missing key #81

Open ghost opened 5 years ago

ghost commented 5 years ago

A missing group_by column does not raise an exception.


In [15]: pd.DataFrame({'a': [1,2,2], 'b': [4,5,6]}) >> group_by('c')                                                                                                                                                                                       
Out[15]:                                                                                                                                                                                                                                                   
   a  b                                                                                                                                                                                                                                                       
0  1  4                                                                                                                                                                                                                                                       
1  2  5                                                                                                                                                                                                                                                       
2  2  6                                                                                                                                                                                                                                                      

In dplyr, the equivalent situation raises an error:

library(tidyverse)
> data.frame(a=c(1,2,2), b=c(4,5,6)) %>% group_by(c)
Error in grouped_df_impl(data, unname(vars), drop) : 
  Column `c` is unknown

My preference would be for this error to raise an exception instead of passing silently.