WIP: Make weekday_name field in DatetimeIndex categorical
State: closed

- [x] closes #12993 
- [ ] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry
Work in progress. `DatetimeIndex` `CategoricalIndex` for `weekday_name` but accessing it from  `dt.weekday_name` still returns an `object` dtype

Labels:
name: Enhancement
name: Datetime
description: Datetime data dtype
name: Categorical
description: Categorical Data Type

Comments:
Thanks for the PR!

`weekday_name` was depreciated in this latest release, so I think it would be more important to apply this feature to `day_name` (and `month_name`). You'll want to make adjustments here: https://github.com/pandas-dev/pandas/blob/v0.23.0/pandas/core/indexes/datetimes.py#L2513-L2537
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21177?src=pr&el=h1) Report
> Merging [#21177](https://codecov.io/gh/pandas-dev/pandas/pull/21177?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/b36b451a74bc16d7ea64c158a3cd33fbfb504068?src=pr&el=desc) will **decrease** coverage by `0.08%`.
> The diff coverage is `n/a`.

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

```diff
@@            Coverage Diff             @@
##           master   #21177      +/-   ##
==========================================
- Coverage   91.92%   91.84%   -0.09%     
==========================================
  Files         153      153              
  Lines       49563    49505      -58     
==========================================
- Hits        45559    45466      -93     
- Misses       4004     4039      +35
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.23% <0%> (-0.09%)` | :arrow_down: |
| #single | `41.88% <0%> (+0.07%)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/21177?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/formats/printing.py](https://codecov.io/gh/pandas-dev/pandas/pull/21177/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvcHJpbnRpbmcucHk=) | `89.38% <0%> (-3.71%)` | :arrow_down: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/21177/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `84.81% <0%> (-1.16%)` | :arrow_down: |
| [pandas/plotting/\_core.py](https://codecov.io/gh/pandas-dev/pandas/pull/21177/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb3JlLnB5) | `82.39% <0%> (-1.15%)` | :arrow_down: |
| [pandas/core/dtypes/missing.py](https://codecov.io/gh/pandas-dev/pandas/pull/21177/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL21pc3NpbmcucHk=) | `91.95% <0%> (-0.58%)` | :arrow_down: |
| [pandas/core/tools/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/21177/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvdG9vbHMvZGF0ZXRpbWVzLnB5) | `84.43% <0%> (-0.55%)` | :arrow_down: |
| [pandas/core/dtypes/cast.py](https://codecov.io/gh/pandas-dev/pandas/pull/21177/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2Nhc3QucHk=) | `88.06% <0%> (-0.43%)` | :arrow_down: |
| [pandas/core/algorithms.py](https://codecov.io/gh/pandas-dev/pandas/pull/21177/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYWxnb3JpdGhtcy5weQ==) | `94.5% <0%> (-0.34%)` | :arrow_down: |
| [pandas/core/indexes/category.py](https://codecov.io/gh/pandas-dev/pandas/pull/21177/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9jYXRlZ29yeS5weQ==) | `97.03% <0%> (-0.25%)` | :arrow_down: |
| [pandas/io/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/21177/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2NvbW1vbi5weQ==) | `70.04% <0%> (-0.25%)` | :arrow_down: |
| [pandas/io/json/json.py](https://codecov.io/gh/pandas-dev/pandas/pull/21177/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2pzb24vanNvbi5weQ==) | `92.23% <0%> (-0.24%)` | :arrow_down: |
| ... and [21 more](https://codecov.io/gh/pandas-dev/pandas/pull/21177/diff?src=pr&el=tree-more) | |

------

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

It's useful to add some tests (even if they fail for now) just to see if the changes are on the right track. 
I find that I have to change the data type in a lot of existing tests by setting ordered and categories properties.
How about creating a custom categorical dtype for month_name and day_name as in https://pandas.pydata.org/pandas-docs/stable/generated/pandas.api.types.CategoricalDtype.html?
If so where can this type be put?
Go ahead and change the dtype in the existing tests. Since this is an API change, the existing tests will need to be adjusted. 
Hello @sivakar12! Thanks for updating the PR.







Cheers ! There are no PEP8 issues in this Pull Request. :beers: 

##### Comment last updated on June 20, 2018 at 18:39 Hours UTC
can you rebase & fixup
OK. I've rebased
closing as stale, if you want to continue working, pls ping and we can re-open. you will need to merge master.