How to group daily data to bi-weekly bins using Plot

Hello!
I found this notebook about discovering date patterns to be extremely useful: https://observablehq.com/@observablehq/discovering-date-patterns

Specifically the part about creating date features and mapping over the raw data with dates and creating a new array with month, year, quarter, and week fields.

I was wondering if anyone knows how to do the same thing but for bi-weekly information.

For example, I’d like to create a bi-week field where something like 1 represents week 1 and 2, 2 represents week 3 and 4, etc.

Hope this makes sense! Thank you.

where you have:

const week = tzdate.weekOfYear;

you could divide by 2:

const biweek = Math.floor(tzdate.weekOfYear/2);

1 Like