polars icon indicating copy to clipboard operation
polars copied to clipboard

Add dt.quarter_start, dt.quarter_end, dt.year_start and dt.year_end

Open SozinM opened this issue 1 year ago • 1 comments

Description

I need date_range capabilities similar to pandas to conveniently get week, quarter, and year starts and ends. I propose to implement quarter_start, quarter_end, year_start and year_end methods from pandas similarly to https://github.com/pola-rs/polars/pull/8435 PR for quarter and year implementation is: #14513 I will add tests and complete documentation once we discuss implementation details.

@mcrumiller and @MarcoGorelli could be interested as you were participating in the #8435

SozinM avatar Feb 15 '24 18:02 SozinM

Discussed today - this would be good to have, isn't trivial for users to do themselves, and opens up for optimisation possibilities which might not be possible if users have to construct the result themselves

Looks like you've already opened a PR, feel free to ping when it's ready!

MarcoGorelli avatar Feb 23 '24 14:02 MarcoGorelli

Thanks! I will do refactoring and tests now

SozinM avatar Feb 28 '24 12:02 SozinM

@mcrumiller @MarcoGorelli Refactoring, Tests and docs are done. Few questions:

  1. Wdyt about naming of pub(crate) enum RollUnit { Month, Quarter, Year, } - maybe there is better fitting name?

  2. Is my approach to the separation of roll_backward into the general function and supplementary ones for specific cases good enough? Or maybe better to use some different approach?

Note: I changed module month_end, month_start to date_end, date_start so we could pack all end and start methods in there and not create new module for each new method.

SozinM avatar Feb 29 '24 18:02 SozinM