Closed akmalsoliev closed 8 months ago
Work In Progress
Issues:
31st of January - 28th of February is still not considered as one whole month.
this looks fine to be honest
say you want to count the whole months between x
and y
, where y
> x
the result is the smallest n
such that x.dt.offset_by(f'{n}mo')
is greater or equal to y
is this correct? shouldn't it be 11?
(Pdb) pl.select(xdt.month_delta(dt.date(1970, 1, 2), dt.date(1971, 1, 1))) shape: (1, 1) ┌─────────┐ │ literal │ │ --- │ │ i32 │ ╞═════════╡ │ 12 │ └─────────┘
Fixed, there was unnecessary month comparison subtraction_condition
that has there from previous commits.
NOTE: Added this to test section too.
thanks for updating!
OK I think the results are correct. Or at least, I wasn't able to break it, even with hypothesis
:)
I'll do another check of the code, and of the performance, as I'd like to think this can be simplified
https://github.com/pola-rs/polars-xdt/pull/66 just fyi (now that we've got a hypothesis test in, we can confidently optimise away 😎 )
The month_diff function computes the integer representation of the month difference between two dates. The resulting values can be both positive and negative, signifying whether the comparative shift from the target date is to the past or the future, respectively.