Skip to content

DOC: read_csv usecols element order is ignored #18729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions doc/source/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ usecols : array-like or callable, default ``None``
be positional (i.e. integer indices into the document columns) or strings
that correspond to column names provided either by the user in `names` or
inferred from the document header row(s). For example, a valid array-like
`usecols` parameter would be [0, 1, 2] or ['foo', 'bar', 'baz'].
`usecols` parameter would be [0, 1, 2] or ['foo', 'bar', 'baz']. Element
order is ignored, so usecols=[0,1] is the same as [1, 0].

If callable, the callable function will be evaluated against the column names,
returning names where the callable function evaluates to True:
Expand Down Expand Up @@ -2822,11 +2823,11 @@ to be parsed.

If `usecols` is a list of integers, then it is assumed to be the file column
indices to be parsed.

.. code-block:: python

read_excel('path_to_file.xls', 'Sheet1', usecols=[0, 2, 3])

Element order is ignored, so usecols=[0,1] is the same as [1,0].

Parsing Dates
+++++++++++++
Expand Down
3 changes: 2 additions & 1 deletion pandas/io/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@
be positional (i.e. integer indices into the document columns) or strings
that correspond to column names provided either by the user in `names` or
inferred from the document header row(s). For example, a valid array-like
`usecols` parameter would be [0, 1, 2] or ['foo', 'bar', 'baz'].
`usecols` parameter would be [0, 1, 2] or ['foo', 'bar', 'baz']. Element
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you also add this note to io.rst

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

order is ignored, so usecols=[1,0] is the same as [0,1].

If callable, the callable function will be evaluated against the column
names, returning names where the callable function evaluates to True. An
Expand Down