Update examples with imports
State: closed

Variable ts1, ts2, and index are never defined in dataframe df. Should ts1 and ts2 be strings and can we get rid of the index variable?

Labels:
name: Docs

Comments:
What do you mean with "variable ts1, ts2,"? 
In which docstring are they included? (I don't see them in the DataFrame one)
@jorisvandenbossche they are in the DataFrame class docstring

```
    Examples
    --------
    >>> d = {'col1': ts1, 'col2': ts2}
    >>> df = DataFrame(data=d, index=index)
    >>> df2 = DataFrame(np.random.randn(10, 5))
    >>> df3 = DataFrame(np.random.randn(10, 5),
    ...                 columns=['a', 'b', 'c', 'd', 'e'])

```

@vparekh94 it'd be nice to expand that a bit with text in between each explaining the data being passed in. Like

```
    Examples
    --------
    From a dictionary of arrays:

    >>> d = {'col1': ts1, 'col2': ts2}
    >>> df = DataFrame(data=d, index=index)

    From a 2-D numpy array:

    >>> df2 = DataFrame(np.random.randn(10, 5))

    Same, but setting the column names:

    >>> df3 = DataFrame(np.random.randn(10, 5),
    ...                 columns=['a', 'b', 'c', 'd', 'e'])

```

(might not have the newlines entirely correct there.
Oh, I was really blind .. :-)

But indeed, @TomAugspurger 's suggestion is the way to go!
@vparekh94 are you able to update this? You can push additional commits to this branch.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16424?src=pr&el=h1) Report
> Merging [#16424](https://codecov.io/gh/pandas-dev/pandas/pull/16424?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/49ec31bbaeca81a6f58fc1be26fe80f3ac188cdd?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `n/a`.

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

```diff
@@            Coverage Diff             @@
##           master   #16424      +/-   ##
==========================================
- Coverage   90.42%   90.42%   -0.01%     
==========================================
  Files         161      161              
  Lines       51023    51023              
==========================================
- Hits        46138    46137       -1     
- Misses       4885     4886       +1
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.26% <ø> (-0.01%)` | :arrow_down: |
| #single | `40.17% <ø> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16424?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/16424?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.69% <ø> (ø)` | :arrow_up: |
| [pandas/core/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/16424?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29tbW9uLnB5) | `91.05% <0%> (-0.34%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16424?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/16424?src=pr&el=footer). Last update [49ec31b...10463c2](https://codecov.io/gh/pandas-dev/pandas/pull/16424?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/16424?src=pr&el=h1) Report
> Merging [#16424](https://codecov.io/gh/pandas-dev/pandas/pull/16424?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/49ec31bbaeca81a6f58fc1be26fe80f3ac188cdd?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `n/a`.

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

```diff
@@            Coverage Diff             @@
##           master   #16424      +/-   ##
==========================================
- Coverage   90.42%   90.42%   -0.01%     
==========================================
  Files         161      161              
  Lines       51023    51023              
==========================================
- Hits        46138    46137       -1     
- Misses       4885     4886       +1
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.26% <ø> (-0.01%)` | :arrow_down: |
| #single | `40.17% <ø> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16424?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/16424?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.69% <ø> (ø)` | :arrow_up: |
| [pandas/core/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/16424?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29tbW9uLnB5) | `91.05% <0%> (-0.34%)` | :arrow_down: |

------

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

can you rebase and update?
@vparekh94 sorry for the oversight on out part, but this has been fixed in the meantime in another PR https://github.com/pandas-dev/pandas/pull/16487. 
Thanks for the contribution anyway!