github.com/tobgu/qframe@v0.4.0/config/groupby/config.go (about) 1 package groupby 2 3 // Config holds configuration for group by operations on QFrames. 4 // It should be considered a private implementation detail and should never be 5 // referenced or used directly outside of the QFrame code. To manipulate it 6 // use the functions returning ConfigFunc below. 7 type Config struct { 8 Columns []string 9 GroupByNull bool 10 // dropNulls? 11 } 12 13 // ConfigFunc is a function that operates on a Config object. 14 type ConfigFunc func(c *Config) 15 16 // NewConfig creates a new Config object. 17 // This function should never be called from outside QFrame. 18 func NewConfig(configFns []ConfigFunc) Config { 19 var config Config 20 for _, f := range configFns { 21 f(&config) 22 } 23 24 return config 25 } 26 27 // Columns sets the columns by which the data should be grouped. 28 // Leaving this configuration option out will group on all columns in the QFrame. 29 // 30 // The order of columns does not matter from a functional point of view but 31 // it may impact execution time a bit. For optimal performance order columns 32 // according to type with the following priority: 33 // 1. int 34 // 2. float 35 // 3. enum/bool 36 // 4. string 37 func Columns(columns ...string) ConfigFunc { 38 return func(c *Config) { 39 c.Columns = columns 40 } 41 } 42 43 // Null configures if Na/nulls should be grouped together or not. 44 // Default is false (eg. don't group null/NaN). 45 func Null(b bool) ConfigFunc { 46 return func(c *Config) { 47 c.GroupByNull = b 48 } 49 }