Skip to content

Commit e88e9db

Browse files
chris-b1TomAugspurger
authored andcommitted
DOC: improve some Excel docstring (#16658)
(cherry picked from commit d915c7e)
1 parent 4e39a06 commit e88e9db

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

doc/source/io.rst

+10
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,16 @@ index column inference and discard the last column, pass ``index_col=False``:
712712
pd.read_csv(StringIO(data))
713713
pd.read_csv(StringIO(data), index_col=False)
714714
715+
If a subset of data is being parsed using the ``usecols`` option, the
716+
``index_col`` specification is based on that subset, not the original data.
717+
718+
.. ipython:: python
719+
720+
data = 'a,b,c\n4,apple,bat,\n8,orange,cow,'
721+
print(data)
722+
pd.read_csv(StringIO(data), usecols=['b', 'c'])
723+
pd.read_csv(StringIO(data), usecols=['b', 'c'], index_col=0)
724+
715725
.. _io.parse_dates:
716726

717727
Date Handling

pandas/io/excel.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@
7979
index_col : int, list of ints, default None
8080
Column (0-indexed) to use as the row labels of the DataFrame.
8181
Pass None if there is no such column. If a list is passed,
82-
those columns will be combined into a ``MultiIndex``
82+
those columns will be combined into a ``MultiIndex``. If a
83+
subset of data is selected with ``parse_cols``, index_col
84+
is based on the subset.
8385
names : array-like, default None
8486
List of column names to use. If file contains no header row,
8587
then you should explicitly pass header=None
@@ -90,7 +92,7 @@
9092
content.
9193
dtype : Type name or dict of column -> type, default None
9294
Data type for data or columns. E.g. {'a': np.float64, 'b': np.int32}
93-
Use `str` or `object` to preserve and not interpret dtype.
95+
Use `object` to preserve data as stored in Excel and not interpret dtype.
9496
If converters are specified, they will be applied INSTEAD
9597
of dtype conversion.
9698
@@ -110,8 +112,9 @@
110112
* If None then parse all columns,
111113
* If int then indicates last column to be parsed
112114
* If list of ints then indicates list of column numbers to be parsed
113-
* If string then indicates comma separated list of column names and
114-
column ranges (e.g. "A:E" or "A,C,E:F")
115+
* If string then indicates comma separated list of Excel column letters and
116+
column ranges (e.g. "A:E" or "A,C,E:F"). Ranges are inclusive of
117+
both sides.
115118
squeeze : boolean, default False
116119
If the parsed data only contains one column then return a Series
117120
na_values : scalar, str, list-like, or dict, default None

0 commit comments

Comments
 (0)