simplify algebra in Year offset apply methods
State: closed

This PR is careful to only touch YearEnd and YearBegin classes, so should not overlap with #18263 or #18278.  But like 18278, once the algebra is simplified, it looks an awful lot like 18263.

The bad news is that the process of simplifying the dynamically-defined `_increment, `_decrement, `_rollf` functions is no fun, and I'm not aware of any good way to "show your work" to walk through the in-between steps.

- [ ] closes #xxxx
- [ ] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry


Labels:
name: Frequency
description: DateOffsets
name: Clean

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18280?src=pr&el=h1) Report
> Merging [#18280](https://codecov.io/gh/pandas-dev/pandas/pull/18280?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/9c799e2c4331e5e42cfda03323eef165feb5be1a?src=pr&el=desc) will **decrease** coverage by `0.02%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/18280/graphs/tree.svg?src=pr&token=eZ4WkYLtcO&width=650&height=150)](https://codecov.io/gh/pandas-dev/pandas/pull/18280?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #18280      +/-   ##
==========================================
- Coverage   91.39%   91.37%   -0.03%     
==========================================
  Files         164      164              
  Lines       49854    49808      -46     
==========================================
- Hits        45566    45511      -55     
- Misses       4288     4297       +9
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.17% <100%> (-0.01%)` | :arrow_down: |
| #single | `39.47% <0%> (-0.03%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/18280?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/tseries/offsets.py](https://codecov.io/gh/pandas-dev/pandas/pull/18280?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvb2Zmc2V0cy5weQ==) | `96.96% <100%> (-0.1%)` | :arrow_down: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/18280?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/18280?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.8% <0%> (-0.1%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18280?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18280?src=pr&el=footer). Last update [9c799e2...369da47](https://codecov.io/gh/pandas-dev/pandas/pull/18280?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

> same question, do we have sufficient tests for this?

As in #18263, I think so, yes.
are there unit tests for these (can you point)?  in particular the raising of get_day_of_month?
> are there unit tests for these (can you point)? in particular the raising of get_day_of_month?

There aren't any specific tests for these.  I'll add some.
yeah i suspect lots of things are not unit tested so taking this opportunity to put in place :)
Sounds good. Another BTW: we can get coverage for _libs: https://github.com/pandas-dev/pandas/issues/12634#issuecomment-338829760
thanks! I love unit tests & doc-strings!