Skip to content

Commit 9c485e3

Browse files
committed
add max and min to groupby
1 parent 30c86bf commit 9c485e3

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

danfojs/src/core/groupby.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,18 @@ export class GroupBy {
306306
return df
307307
}
308308

309+
max(){
310+
let value = this.arithemetic("max()")
311+
let df = this.to_DataFrame(this.key_col, this.group_col_name,value,"max")
312+
return df
313+
}
314+
315+
min(){
316+
let value = this.arithemetic("min()")
317+
let df = this.to_DataFrame(this.key_col, this.group_col_name,value,"min")
318+
return df
319+
}
320+
309321
/**
310322
* returns dataframe of a group
311323
* @param {*} key [Array]
@@ -396,7 +408,7 @@ export class GroupBy {
396408
}
397409
let column = [...key_col]
398410
let group_col = col.slice().map((x,i)=>{
399-
if(ops.length >1){
411+
if(Array.isArray(ops)){
400412
return `${x}_${ops[i]}`
401413
}
402414
return `${x}_${ops}`

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"table": "^5.4.6"
2323
},
2424
"scripts": {
25-
"test": "nyc mocha --require @babel/register danfojs/tests/*",
25+
"test": "nyc mocha --require @babel/register danfojs/tests/core/groupby",
2626
"dev": "npm run lint && babel ./danfojs/src -d dist --no-comments",
2727
"build": "babel ./danfojs/src -d ./dist --no-comments",
2828
"lint": "eslint ./danfojs/src",

0 commit comments

Comments
 (0)