Groupby.sum
Obtain the sum per groups for columns
const dfd = require("danfojs-node")
let data ={A: ['foo', 'bar', 'foo', 'bar',
'foo', 'bar', 'foo', 'foo'],
B: ['one', 'one', 'two', 'three',
'two', 'two', 'one', 'three'],
C: [1,3,2,4,5,2,6,7],
D: [3,2,4,1,5,6,7,8]
}
let df = new dfd.DataFrame(data)
let grp = df.groupby(["A"])
grp.col(["C"]).sum().print()╔═══╤═══════════════════╤═══════════════════╗
║ │ A │ C_sum ║
╟───┼───────────────────┼───────────────────╢
║ 0 │ foo │ 21 ║
╟───┼───────────────────┼───────────────────╢
║ 1 │ bar │ 9 ║
╚═══╧═══════════════════╧═══════════════════╝Last updated