Skip to content

Commit 51674c3

Browse files
committed
implement common groupby accessories function
1 parent eef1c48 commit 51674c3

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/danfojs-base/aggregators/groupby.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ export default class Groupby {
400400
let colDict: { [key: string ]: DataFrame | Series } = {}
401401
for(const [key, values] of Object.entries(this.colDict)) {
402402
let valDataframe = new DataFrame(values)
403+
valDataframe.print()
403404
colDict[key] = callable(valDataframe)
404405
}
405406
return this.concatGroups(colDict)
@@ -428,4 +429,19 @@ export default class Groupby {
428429
}
429430
return concat({dfList: data, axis:0}) as DataFrame
430431
}
432+
433+
get ngroups(): number{
434+
let keys = Object.keys(this.colDict)
435+
return keys.length
436+
}
437+
438+
get groups(): {[keys: string]: {}}{
439+
return this.colDict
440+
}
441+
442+
ngroup(nth: number) {
443+
const values = Object.values(this.colDict)
444+
const nvalue = values[nth]
445+
return new DataFrame(nvalue)
446+
}
431447
}

0 commit comments

Comments
 (0)