Skip to content

Commit 4de5cdc

Browse files
gfyoungjorisvandenbossche
authored andcommitted
DOC: Add example of skipcols in read_csv (#15052)
Illustrate how we can use the "usecols" argument to skip particular columns. Closes gh-10882.
1 parent 018414e commit 4de5cdc

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

doc/source/io.rst

+9
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,15 @@ file, either using the column names, position numbers or a callable:
644644
pd.read_csv(StringIO(data), usecols=[0, 2, 3])
645645
pd.read_csv(StringIO(data), usecols=lambda x: x.upper() in ['A', 'C'])
646646
647+
The ``usecols`` argument can also be used to specify which columns not to
648+
use in the final result:
649+
650+
.. ipython:: python
651+
pd.read_csv(StringIO(data), usecols=lambda x: x not in ['a', 'c'])
652+
653+
In this case, the callable is specifying that we exclude the "a" and "c"
654+
columns from the output.
655+
647656
Comments and Empty Lines
648657
''''''''''''''''''''''''
649658

0 commit comments

Comments
 (0)