Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support automatic time binning #427

Closed
domoritz opened this issue Jun 7, 2024 · 3 comments · Fixed by #435
Closed

Support automatic time binning #427

domoritz opened this issue Jun 7, 2024 · 3 comments · Fixed by #435

Comments

@domoritz
Copy link
Member

domoritz commented Jun 7, 2024

It would vibe great if Mosaic had a way to bin time fields by time units (month, day etc) similar to https://vega.github.io/vega-lite/docs/timeunit.html and bin automatically by the most appropriate time unit.

Previous discussion at #283 (comment)

@domoritz
Copy link
Member Author

domoritz commented Jun 7, 2024

@hamilton wrote a blog post about a query to determine the smallest time unit used in some data which could be useful for heuristics here as well: https://www.hamiltonulmer.com/smallest-timegrain-heuristic/.

@jheer
Copy link
Member

jheer commented Jun 7, 2024

Mosaic does support time binning. First, one can directly use existing DuckDB date part methods like quarter, month, dayofweek, etc. To bin a date without changing the type (resulting in a JS Date object in the browser), mosaic-sql includes the methods dateMonth, dateMonthDay, and dateDay. I agree that a method for automatically determining a "nice" binning unit could be helpful!

p.s. FWIW the bin transform supports temporal values as well, but treats them as numbers, currently without consideration for nice units.

@derekperkins
Copy link

Not sure if this would fall under Mosaic or DuckDB, but it would also be nice to handle day of week alignment when binning, for MoM and YoY

@domoritz domoritz changed the title Support time binning Support automatic time binning Jun 7, 2024
@jheer jheer mentioned this issue Jun 24, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants