Continue porting period_helper; fix leftover asfreq bug by jbrockmendel · Pull Request #19834 · pandas-dev/pandas (original) (raw)

In #19650 we fixed a bug with asfreq but missed a weekly-frequency case. This fixes and tests that. I'll see if I can cook up a more thorough set of tests to make sure nothing else slips through the cracks.

Other than that, the main thing this does is substitute in ORD_OFFSET = WEEK_OFFSET * 7 + 4 and BDAY_OFFSET = 5 * WEEK_OFFSET + 4 and then cleans up some algebra (which is now OK because we are using non-cdivision floordiv and mod). As a result we get rid of a bunch of calls that add ORD_OFFSET just to subtract it a few lines later.

Gets rid of CamelCase in tslibs.period, moves towards using pandas_datetimestruct directly and getting rid of the redundant date_info.

Catches a RuntimeWarning in the tests; closes #19767.