API: Implement set_freq for DTI/TDI, deprecate freq setter
State: closed

- [X] closes #20886
- [X] tests added / passed
- [X] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [X] whatsnew entry

Summary:
- Follow-up to #20772
  - See that PR for relevant discussion
- Implements a `set_freq` method for `DatetimeIndex` and `TimedeltaIndex`
- Deprecates the `freq` setter for `DatetimeIndex` and `TimedeltaIndex`
   - Had to change some instances of the DTI/TDI implementation to directly set the `_freq` attribute
   - Had to modify some tests to use `set_freq` instead of the setter
   - Didn't see any related deprecation warnings in the logs from the CI runs hooked to my local repo


cc @jreback @jorisvandenbossche 

Labels:
name: Datetime
description: Datetime data dtype
name: API Design
name: Frequency
description: DateOffsets
name: Deprecate
description: Functionality to remove in pandas

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/20892?src=pr&el=h1) Report
> Merging [#20892](https://codecov.io/gh/pandas-dev/pandas/pull/20892?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/28dbae9f306ade549eb1edd5484b3e1da758bcdb?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #20892      +/-   ##
==========================================
+ Coverage   91.81%   91.81%   +<.01%     
==========================================
  Files         153      153              
  Lines       49479    49491      +12     
==========================================
+ Hits        45428    45441      +13     
+ Misses       4051     4050       -1
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.21% <100%> (ø)` | :arrow_up: |
| #single | `41.83% <20.83%> (-0.02%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/20892?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexes/timedeltas.py](https://codecov.io/gh/pandas-dev/pandas/pull/20892/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy90aW1lZGVsdGFzLnB5) | `91.15% <100%> (ø)` | :arrow_up: |
| [pandas/core/indexes/datetimelike.py](https://codecov.io/gh/pandas-dev/pandas/pull/20892/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZWxpa2UucHk=) | `96.85% <100%> (+0.05%)` | :arrow_up: |
| [pandas/core/indexes/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/20892/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZXMucHk=) | `95.77% <100%> (+0.01%)` | :arrow_up: |
| [pandas/core/resample.py](https://codecov.io/gh/pandas-dev/pandas/pull/20892/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvcmVzYW1wbGUucHk=) | `96.07% <100%> (ø)` | :arrow_up: |
| [pandas/core/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/20892/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYmFzZS5weQ==) | `97.05% <0%> (+0.22%)` | :arrow_up: |

------

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

Added `set_freq` to `api.rst`
nice PR @jschendel , lgtm.

any comments @jorisvandenbossche @TomAugspurger 
@jorisvandenbossche you commented on the issue. but this PR looks pretty good to me, and it allows chained operations, something we like, not to mention ``.dt`` friendliness. 
This has a merge conflict in the release notes now.

I'm 50/50 on the changes here, will wait for @jorisvandenbossche to review.
As I commented on the issue, I still don't see the need or added value to add a new method for this (and yes, this is a nicely done PR, that's not my problem :-)). See https://github.com/pandas-dev/pandas/issues/20886#issuecomment-386710752

BTW, I don't feel strongly about this (as it is something I will never use), so I am fine to go with the majority if there is one, I just have the feeling we are adding a new method for something we don't need (and the bar to add new methods should be higher)
ok, closing this. thanks for the PR @jschendel we can revisit in the future if more interest.