DOC: pandas.DateTimeIndex.to_frame
State: closed

Checklist for the pandas documentation sprint (ignore this if you are doing
an unrelated PR):

- [ X] PR title is "DOC: pandas.DateTimeIndex.to_frame"
- [X ] The validation script passes: `./scripts/validate_docstrings.py pandas.DatetimeIndex.to_frame`
- [ X] The PEP8 style check passes: `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [X ] The html version looks good: `python doc/make.py --single pandas.DatetimeIndex.to_frame`
- [ X] It has been proofread on language by another sprint participant

Please include the output of the validation script below between the "```" ticks:

```
################################################################################
################## Docstring (pandas.DatetimeIndex.to_frame)  ##################
################################################################################

Create a DataFrame with a column containing the Index.

.. versionadded:: 0.21.0

Parameters
----------
index : boolean, default True
    Set the index of the returned DataFrame as the original Index.

Returns
-------
DataFrame
    DataFrame containing the original Index data.

Examples
--------
>>> idx = pd.Index(['Ant', 'Bear', 'Cow'], name='animal')
>>> idx.to_frame()
    animal
animal       
Ant       Ant
Bear     Bear
Cow       Cow

By default, the original Index is reused. To enforce a new Index:

>>> idx.to_frame(index=False)
    animal
0   Ant
1  Bear
2   Cow

Application to datetimes

>>> dt = ['04/27/2008 05:28 AM', '04/22/2008 07:19 AM',
...       '10/09/2008 01:44 PM', '12/25/2008 09:50 AM',
...       '08/19/2008 07:30 PM', '03/07/2008 11:04 PM',
...       '12/22/2008 12:08 PM', '07/01/2008 05:36 AM', 
...       '09/06/2008 04:53 AM', '01/23/2008 07:43 PM']
>>> con_dt = pd.to_datetime(dt)
>>> df = con_dt.to_frame(index=True)
>>> df[0]
2008-04-27 05:28:00   2008-04-27 05:28:00
2008-04-22 07:19:00   2008-04-22 07:19:00
2008-10-09 13:44:00   2008-10-09 13:44:00
2008-12-25 09:50:00   2008-12-25 09:50:00
2008-08-19 19:30:00   2008-08-19 19:30:00
2008-03-07 23:04:00   2008-03-07 23:04:00
2008-12-22 12:08:00   2008-12-22 12:08:00
2008-07-01 05:36:00   2008-07-01 05:36:00
2008-09-06 04:53:00   2008-09-06 04:53:00
2008-01-23 19:43:00   2008-01-23 19:43:00
Name: 0, dtype: datetime64[ns]

See Also
--------
pandas.Series.to_frame : Convert Series to DataFrame

################################################################################
################################## Validation ##################################
################################################################################

Docstring for "pandas.DatetimeIndex.to_frame" correct. :)
```

If the validation script still gives errors, but you think there is a good reason
to deviate in this case (and there are certainly such cases), please state this
explicitly.



Labels:
name: Docs

Comments:
Hello @ryananyangu! Thanks for updating the PR.



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

##### Comment last updated on March 16, 2018 at 21:20 Hours UTC
@ryananyangu can you edit the title of the PR to be "DOC: pandas.DateTimeIndex.to_frame" instead of "Jovixe"? That'll help us review it. Thanks!
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/20139?src=pr&el=h1) Report
> Merging [#20139](https://codecov.io/gh/pandas-dev/pandas/pull/20139?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/840d4323935348a890d6b868f2b18e8dddd22199?src=pr&el=desc) will **decrease** coverage by `0.02%`.
> The diff coverage is `n/a`.

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

```diff
@@            Coverage Diff             @@
##           master   #20139      +/-   ##
==========================================
- Coverage   91.72%    91.7%   -0.03%     
==========================================
  Files         150      150              
  Lines       49156    49152       -4     
==========================================
- Hits        45090    45074      -16     
- Misses       4066     4078      +12
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.08% <ø> (-0.03%)` | :arrow_down: |
| #single | `41.84% <ø> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/20139?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexes/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/20139/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9iYXNlLnB5) | `96.66% <ø> (-0.01%)` | :arrow_down: |
| [pandas/plotting/\_converter.py](https://codecov.io/gh/pandas-dev/pandas/pull/20139/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb252ZXJ0ZXIucHk=) | `65.07% <0%> (-1.74%)` | :arrow_down: |
| [pandas/core/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/20139/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYmFzZS5weQ==) | `96.78% <0%> (-0.02%)` | :arrow_down: |
| [pandas/core/series.py](https://codecov.io/gh/pandas-dev/pandas/pull/20139/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc2VyaWVzLnB5) | `93.85% <0%> (-0.01%)` | :arrow_down: |
| [pandas/core/indexes/multi.py](https://codecov.io/gh/pandas-dev/pandas/pull/20139/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9tdWx0aS5weQ==) | `95.06% <0%> (ø)` | :arrow_up: |
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/20139/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `95.84% <0%> (ø)` | :arrow_up: |
| [pandas/plotting/\_core.py](https://codecov.io/gh/pandas-dev/pandas/pull/20139/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb3JlLnB5) | `82.23% <0%> (ø)` | :arrow_up: |

------

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

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/20139?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@34649f2`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `n/a`.

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

```diff
@@            Coverage Diff            @@
##             master   #20139   +/-   ##
=========================================
  Coverage          ?    91.7%           
=========================================
  Files             ?      150           
  Lines             ?    49152           
  Branches          ?        0           
=========================================
  Hits              ?    45074           
  Misses            ?     4078           
  Partials          ?        0
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.08% <ø> (?)` | |
| #single | `41.84% <ø> (?)` | |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/20139?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexes/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/20139/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9iYXNlLnB5) | `96.66% <ø> (ø)` | |

------

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

Thanks @ryananyangu !