Fix offset __inits__, apply_index dtypes
State: closed

This PR does two main things:

1) Change the default kwargs for offset `__init__` methods so that the defaults are valid; ATM `WeekOfMonth()` and `LastWeekOfMonth()` will both raise  `ValueError`.

2) ATM `Week.apply_index` adds an int64 array to a `DatetimeIndex`.  This happens to have the desired output because the int64 array represents nanoseconds.  This explicitly casts the array to `timedelta64[ns]` to make this explicit.  <b>This is a necessary step towards fixing #19123.</b>

In addition there are two small pieces of refactoring:

3) Remove `liboffsets.EndMixin` since it is only mixed in to `Week`.

4) Use `liboffsets.roll_convention` to de-duplicate some code in `liboffsets.shift_months`.


- [ ] closes #xxxx
- [ ] tests added / passed
- [ ] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry


Labels:
name: Frequency
description: DateOffsets
name: Clean

Comments:
Travis looks like a moto problem.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/19142?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@27a5039`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff            @@
##             master   #19142   +/-   ##
=========================================
  Coverage          ?   91.52%           
=========================================
  Files             ?      147           
  Lines             ?    48785           
  Branches          ?        0           
=========================================
  Hits              ?    44651           
  Misses            ?     4134           
  Partials          ?        0
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.89% <100%> (?)` | |
| #single | `41.61% <26.31%> (?)` | |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/19142?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/tseries/offsets.py](https://codecov.io/gh/pandas-dev/pandas/pull/19142/diff?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvb2Zmc2V0cy5weQ==) | `97.09% <100%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/19142?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/19142?src=pr&el=footer). Last update [27a5039...4ea4e1e](https://codecov.io/gh/pandas-dev/pandas/pull/19142?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

> where is the test for this? why isn't it raising currently?

Until a few dozen PRs ago all that was passed to `__init__` was `n=1, normalize=False, **kwargs`.  The tests had to explicitly pass the relevant kwargs or else you'd get a `KeyError`.  So there aren't any tests that use the defaults.
> Until a few dozen PRs ago all that was passed to __init__ was n=1, normalize=False, **kwargs. The tests had to explicitly pass the relevant kwargs or else you'd get a KeyError. So there aren't any tests that use the defaults.

ok can you add some pls.
since ``pd.offsets.WeekOfMonth()`` now works, pls add a note in bug fixes for whatsnew. otherwise lgtm. ping on green.
ping
thanks!