Update documentation of read_csv to explain that index_col can be a string containg a column name
State: closed

Uses the suggestion from #22276 and closes #22276.

Labels:
name: Docs
name: IO CSV
description: read_csv, to_csv

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25502?src=pr&el=h1) Report
> Merging [#25502](https://codecov.io/gh/pandas-dev/pandas/pull/25502?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/011f0a6ebacb13619bf8225b3bc2370872b85769?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

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

```diff
@@           Coverage Diff           @@
##           master   #25502   +/-   ##
=======================================
  Coverage   91.75%   91.75%           
=======================================
  Files         173      173           
  Lines       52955    52955           
=======================================
  Hits        48589    48589           
  Misses       4366     4366
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.32% <ø> (ø)` | :arrow_up: |
| #single | `41.72% <ø> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25502?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/parsers.py](https://codecov.io/gh/pandas-dev/pandas/pull/25502/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3BhcnNlcnMucHk=) | `95.34% <ø> (ø)` | :arrow_up: |

------

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

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

```diff
@@            Coverage Diff             @@
##           master   #25502      +/-   ##
==========================================
- Coverage   91.75%   91.25%   -0.51%     
==========================================
  Files         173      172       -1     
  Lines       52955    52977      +22     
==========================================
- Hits        48589    48342     -247     
- Misses       4366     4635     +269
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.82% <ø> (-0.5%)` | :arrow_down: |
| #single | `41.74% <ø> (+0.02%)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25502?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/parsers.py](https://codecov.io/gh/pandas-dev/pandas/pull/25502/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3BhcnNlcnMucHk=) | `95.34% <ø> (ø)` | :arrow_up: |
| [pandas/core/panel.py](https://codecov.io/gh/pandas-dev/pandas/pull/25502/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvcGFuZWwucHk=) | `35.72% <0%> (-36.03%)` | :arrow_down: |
| [pandas/core/sparse/series.py](https://codecov.io/gh/pandas-dev/pandas/pull/25502/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc3BhcnNlL3Nlcmllcy5weQ==) | `93.3% <0%> (-2.24%)` | :arrow_down: |
| [pandas/core/indexing.py](https://codecov.io/gh/pandas-dev/pandas/pull/25502/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhpbmcucHk=) | `90.88% <0%> (-1.41%)` | :arrow_down: |
| [pandas/core/internals/managers.py](https://codecov.io/gh/pandas-dev/pandas/pull/25502/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzL21hbmFnZXJzLnB5) | `93.92% <0%> (-0.92%)` | :arrow_down: |
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/25502/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `93.51% <0%> (-0.65%)` | :arrow_down: |
| [pandas/core/tools/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/25502/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvdG9vbHMvZGF0ZXRpbWVzLnB5) | `84.63% <0%> (-0.5%)` | :arrow_down: |
| [pandas/io/pytables.py](https://codecov.io/gh/pandas-dev/pandas/pull/25502/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3B5dGFibGVzLnB5) | `90.11% <0%> (-0.09%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/25502/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `96.79% <0%> (-0.06%)` | :arrow_down: |
| [pandas/core/config.py](https://codecov.io/gh/pandas-dev/pandas/pull/25502/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29uZmlnLnB5) | `87% <0%> (-0.05%)` | :arrow_down: |
| ... and [26 more](https://codecov.io/gh/pandas-dev/pandas/pull/25502/diff?src=pr&el=tree-more) | |

------

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

whitespace issue:
https://dev.azure.com/pandas-dev/pandas/_build/results?buildId=9437

On Thu, Mar 14, 2019 at 8:10 AM Jacob Bundgaard <notifications@github.com>
wrote:

> *@kimsey0* commented on this pull request.
> ------------------------------
>
> In pandas/io/parsers.py
> <https://github.com/pandas-dev/pandas/pull/25502#discussion_r265559601>:
>
> > @@ -102,11 +102,14 @@
>      List of column names to use. If file contains no header row, then you
>      should explicitly pass ``header=None``. Duplicates in this list will cause
>      a ``UserWarning`` to be issued.
> -index_col : int, sequence or bool, optional
> -    Column to use as the row labels of the DataFrame. If a sequence is given, a
> -    MultiIndex is used. If you have a malformed file with delimiters at the end
> -    of each line, you might consider ``index_col=False`` to force pandas to
> -    not use the first column as the index (row names).
> +index_col : int, str, sequence of int / str, or False, default ``None``
> +  Column(s) to use as the row labels of the ``DataFrame``, either given as
> +  string name or column index. If a sequence of int / str is given, a
> +  MultiIndex is used. Columns used for the index (row names) are dropped from
> +  the actual columns of the input dataframe. They are accessible via
> +  ``.index``. (Note: ``index_col=False`` can be used to force pandas to *not*
>
> Like this? (I'm not sure why this is duplicated across code comments and
> documentation in the first place instead of being included from the code
> when compiling the documentation, but if it's to be fixed, it should
> probably be in another pull request.)
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/25502#discussion_r265559601>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABQHIhZ-TsBxvM8nS56Oyv6ewcTJWsvOks5vWkpFgaJpZM4bY980>
> .
>

Oops! I didn't notice that there's no spaces on the empty lines. It's fixed now.
lgtm. unless anyone has comments.
Thanks @kimsey0!
Thanks for getting it merged.