ISSUE #44933 : Components function for DateTime data type
State: closed

- [x]  closes #44933
- [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature
- [x] Tests added 
- [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit).
- [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions.
- [x] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.


Labels:
name: Stale

Comments:
@MarcoGorelli @WillAyd I created a test case for it in `pandas/tests/indexes/datetimes/test_scalar_compat.py` but after reading contribution guide I feel as if I should be implementing it in a package instead however having a hard time figuring out where based on the instructions. 
nice! haven't looked at where a test would go yet, I'd suggest checking where the tests for timedelta.components are, and seeing if there's an equivalent place for timestamp
@MarcoGorelli I implemented the test case in test_timestamp, however im still getting the error that components does not exist and I am not sure why, could you take a look when you have the chance?
from a quick look
```python
dt = ts.to_pydatetime
```
I guess this was meant to be called, i.e.
```
dt = ts.to_pydatetime()
```
?

though I'm not sure why you need `to_pydatetime` - aren't you adding `components` to `Timestamp` itself? if so, you probably want to check `ts.components`?
@MarcoGorelli isn't the function supposed to be to returning the components of datetime datatype? I started by implementing the timestamp components but I am also implementing datetime components function as well should I not be doing both?

`datetime` itself is a Python built-in, we shouldn't be adding things to that, we should be implementing `components` for pandas' Timestamp (and thereafter, pandas' DatetimeIndex)
@MarcoGorelli oh ok! In Class DatetimeIndex in `pandas/core/indexes/datetimes.py`?
possibly, but let's start by getting `Timestamp.components` to work 💪 

so - could you first please revert the changes you made to `pandas/core/indexes/datetimes.py`?

Then, locally, try running `pytest pandas/tests/scalar/timestamp/test_timestamp.py`, and let's see if we can get that to pass

Once that passes, we can add `components` to the `.dt` accessor
for the docs build error, you'll probably need to add `components` here

https://github.com/pandas-dev/pandas/blob/b63d35d2c6b6587dfb5c6d79e2e48db82d7f3cf0/doc/source/reference/arrays.rst#L148-L149

(just like is done below for `timedelta`)
This pull request is stale because it has been open for thirty days with no activity. Please [update](https://pandas.pydata.org/pandas-docs/stable/development/contributing.html#updating-your-pull-request) and respond to this comment if you're still interested in working on this.
this was off to a good start - @jgarba are you still interested in working on this, or should one of us finish it off? happy to help out if the former, but the latter is also fine. There's no deadline / urgency for this feature so if you'd like to come back to it later, that's fine
Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen.