🏠 back to Observable

d3.rollup on csv multiple column

Hi Team,
I have time-series csv data with multiple columns. My goal is to group the data by month, week, or day and draw a multiline graph.
I am using d3.nest to use “time” columns as key and accordingly want to sum other columns using d3.rollup, depending on the week, month, or day.

I am looking for a generic solution rather than calling on each column. As the number of columns is not fixed.
Data:
Capture

Output expected:
Capture1

Just started with js and d3 and loving it. Thanks!

You can map over the columns that you want to sum in the reducing function that you pass to d3.rollup. I made a notebook to show one possible way to do this.

1 Like

Thank you, man! this is great.