modified changes for datetime and NaT Objects Behavior closes #43280
State: closed

- [ #] Closes #43280
- [ #] tests added / passed

**Modified  datatime object 👍 ** 
i have changed view values to numeric of date and missing data found in pd series is returns Nan when coerce errors . 

**Example for solved changes 💯 **
```
>>> pd.to_numeric(pd.Series(datetime(2021, 8, 22)), errors="coerce")
[OUT]
0    20210822
dtype: int64

>>> pd.to_numeric(pd.Series(pd.NaT), errors="coerce")
[OUT]
0   NaN
dtype: float64

>>> s = pd.to_numeric(datetime(2021, 8, 22), errors="coerce")
0 20210822
dtype: Int64
>>> s = pd.to_numeric(pd.NaT, errors="coerce")
 nan

```



Labels:

Comments:
Hello @Navaneethan2503! Thanks for updating this PR. We checked the lines you've touched for [PEP 8](https://www.python.org/dev/peps/pep-0008) issues, and found:

* In the file [`pandas/core/tools/numeric.py`](https://github.com/pandas-dev/pandas/blob/a4ae1cc1d643d2cf2e82471c542a69244310b408/pandas/core/tools/numeric.py):

> [Line 162:23](https://github.com/pandas-dev/pandas/blob/a4ae1cc1d643d2cf2e82471c542a69244310b408/pandas/core/tools/numeric.py#L162): [E271](https://duckduckgo.com/?q=pep8%20E271) multiple spaces after keyword
> [Line 185:14](https://github.com/pandas-dev/pandas/blob/a4ae1cc1d643d2cf2e82471c542a69244310b408/pandas/core/tools/numeric.py#L185): [W291](https://duckduckgo.com/?q=pep8%20W291) trailing whitespace

* In the file [`pandas/tests/tools/test_to_numeric.py`](https://github.com/pandas-dev/pandas/blob/a4ae1cc1d643d2cf2e82471c542a69244310b408/pandas/tests/tools/test_to_numeric.py):

> [Line 795:5](https://github.com/pandas-dev/pandas/blob/a4ae1cc1d643d2cf2e82471c542a69244310b408/pandas/tests/tools/test_to_numeric.py#L795): [E265](https://duckduckgo.com/?q=pep8%20E265) block comment should start with '# '
> [Line 800:1](https://github.com/pandas-dev/pandas/blob/a4ae1cc1d643d2cf2e82471c542a69244310b408/pandas/tests/tools/test_to_numeric.py#L800): [E302](https://duckduckgo.com/?q=pep8%20E302) expected 2 blank lines, found 1
> [Line 801:5](https://github.com/pandas-dev/pandas/blob/a4ae1cc1d643d2cf2e82471c542a69244310b408/pandas/tests/tools/test_to_numeric.py#L801): [E265](https://duckduckgo.com/?q=pep8%20E265) block comment should start with '# '
> [Line 806:1](https://github.com/pandas-dev/pandas/blob/a4ae1cc1d643d2cf2e82471c542a69244310b408/pandas/tests/tools/test_to_numeric.py#L806): [E302](https://duckduckgo.com/?q=pep8%20E302) expected 2 blank lines, found 1
> [Line 807:5](https://github.com/pandas-dev/pandas/blob/a4ae1cc1d643d2cf2e82471c542a69244310b408/pandas/tests/tools/test_to_numeric.py#L807): [E265](https://duckduckgo.com/?q=pep8%20E265) block comment should start with '# '
> [Line 812:1](https://github.com/pandas-dev/pandas/blob/a4ae1cc1d643d2cf2e82471c542a69244310b408/pandas/tests/tools/test_to_numeric.py#L812): [E302](https://duckduckgo.com/?q=pep8%20E302) expected 2 blank lines, found 1
> [Line 813:5](https://github.com/pandas-dev/pandas/blob/a4ae1cc1d643d2cf2e82471c542a69244310b408/pandas/tests/tools/test_to_numeric.py#L813): [E265](https://duckduckgo.com/?q=pep8%20E265) block comment should start with '# '
> [Line 816:1](https://github.com/pandas-dev/pandas/blob/a4ae1cc1d643d2cf2e82471c542a69244310b408/pandas/tests/tools/test_to_numeric.py#L816): [W391](https://duckduckgo.com/?q=pep8%20W391) blank line at end of file



##### Comment last updated at 2021-08-31 14:28:48 UTC
Hi @Navaneethan2503, thank you for this PR. I think that this solves the problem for `pd.NaT`, but there is still an inconsistency for scalar arguments vs `pd.Series`:
```python
>>> import pandas as pd
>>> from datetime import datetime
>>> pd.to_numeric(pd.Series(datetime(2021,8,22)), errors="coerce")
0    20210822
dtype: int64
>>> pd.to_numeric(datetime(2021,8,22), errors="coerce")
nan
```
Additionally, I am not sure that the idea is to change the current behavior of datetime series for a new one. Instead, the idea should be to apply the current behavior to scalar arguments.
> Hi @Navaneethan2503, thank you for this PR. I think that this solves the problem for `pd.NaT`, but there is still an inconsistency for scalar arguments vs `pd.Series`:
> 
> ```python
> >>> import pandas as pd
> >>> from datetime import datetime
> >>> pd.to_numeric(pd.Series(datetime(2021,8,22)), errors="coerce")
> 0    20210822
> dtype: int64
> >>> pd.to_numeric(datetime(2021,8,22), errors="coerce")
> nan
> ```
> 
> Additionally, I am not sure that the idea is to change the current behavior of datetime series for a new one. Instead, the idea should be to apply the current behavior to scalar arguments.

I thing all scalar argument are passed , my suggestion idea is good because datatime behaviour are all type passed
Final PR pass all scalar arguments including datetime and NaT DataType , make it merge
Thanks for the PR but it appears this is a duplicate of https://github.com/pandas-dev/pandas/pull/43315 which is a little further along. Closing as a duplicate but happy to have you work on other issues with a `good first issue` label.