Skip to content

Commit fda8fa2

Browse files
committed
DOC: read_excel doc - fixed formatting and added examples
1 parent c56da89 commit fda8fa2

File tree

3 files changed

+16
-34
lines changed

3 files changed

+16
-34
lines changed

doc/source/whatsnew/v0.22.0.txt

-2
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,8 @@ Other API Changes
5959
- :func:`pandas.DataFrame.merge` no longer casts a ``float`` column to ``object`` when merging on ``int`` and ``float`` columns (:issue:`16572`)
6060
- The default NA value for :class:`UInt64Index` has changed from 0 to ``NaN``, which impacts methods that mask with NA, such as ``UInt64Index.where()`` (:issue:`18398`)
6161
- Refactored ``setup.py`` to use ``find_packages`` instead of explicitly listing out all subpackages (:issue:`18535`)
62-
- Rearranged the order of keyword arguments in :func:`read_excel()` to align with :func:`read_csv()` (:issue:`16672`)
6362
- :func:`pandas.merge` now raises a ``ValueError`` when trying to merge on incompatible data types (:issue:`9780`)
6463
- :func:`wide_to_long` previously kept numeric-like suffixes as ``object`` dtype. Now they are cast to numeric if possible (:issue:`17627`)
65-
- in :func:`read_excel`, the ``comment`` argument is now exposed as a named parameter (:issue:`18735`)
6664

6765
.. _whatsnew_0220.deprecations:
6866

doc/source/whatsnew/v0.23.0.txt

+2
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ Other API Changes
203203
- Rearranged the order of keyword arguments in :func:`read_excel()` to align with :func:`read_csv()` (:issue:`16672`)
204204
- :func:`pandas.merge` now raises a ``ValueError`` when trying to merge on incompatible data types (:issue:`9780`)
205205
- :func:`wide_to_long` previously kept numeric-like suffixes as ``object`` dtype. Now they are cast to numeric if possible (:issue:`17627`)
206+
- In :func:`read_excel`, the ``comment`` argument is now exposed as a named parameter (:issue:`18735`)
207+
- Rearranged the order of keyword arguments in :func:`read_excel()` to align with :func:`read_csv()` (:issue:`16672`)
206208

207209
.. _whatsnew_0230.deprecations:
208210

pandas/io/excel.py

+14-32
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,13 @@
132132
nrows : int, default None
133133
Number of rows to parse
134134
135-
.. versionadded:: 0.23.0
135+
.. versionadded:: 0.22.0
136136
137137
na_values : scalar, str, list-like, or dict, default None
138138
Additional strings to recognize as NA/NaN. If dict passed, specific
139139
per-column NA values. By default the following values are interpreted
140-
as NaN: '""" + fill("', '".join(sorted(_NA_VALUES)), 999) + """'.
140+
as NaN: '""" + fill("', '".join(sorted(_NA_VALUES)), 70,
141+
subsequent_indent=" ") + """'.
141142
keep_default_na : bool, default True
142143
If na_values are specified and keep_default_na is False the default NaN
143144
values are overridden, otherwise they're appended to.
@@ -154,7 +155,7 @@
154155
comment string and the end of the current line is ignored.
155156
skip_footer : int, default 0
156157
157-
.. deprecated:: 0.23.0
158+
.. deprecated:: 0.22.0
158159
Pass in `skipfooter` instead.
159160
skipfooter : int, default 0
160161
Rows at the end to skip (0-indexed)
@@ -177,7 +178,7 @@
177178
>>> df_out = pd.DataFrame([('string1', 1),
178179
... ('string2', 2),
179180
... ('string3', 3)],
180-
... columns=('Name', 'Value'))
181+
... columns=['Name', 'Value'])
181182
>>> df_out
182183
Name Value
183184
0 string1 1
@@ -201,7 +202,7 @@
201202
202203
Index and header can be specified via the `index_col` and `header` arguments
203204
204-
>>> pd.read_excel(open('tmp.xlsx','rb'), index_col=None, header=None)
205+
>>> pd.read_excel('tmp.xlsx', index_col=None, header=None)
205206
0 1 2
206207
0 NaN Name Value
207208
1 0.0 string1 1
@@ -210,7 +211,7 @@
210211
211212
Column types are inferred but can be explicitly specified
212213
213-
>>> pd.read_excel(open('tmp.xlsx','rb'), dtype={'Name':str, 'Value':float})
214+
>>> pd.read_excel('tmp.xlsx', dtype={'Name':str, 'Value':float})
214215
Name Value
215216
0 string1 1.0
216217
1 string2 2.0
@@ -220,7 +221,7 @@
220221
but can be explicitly specified, too. Supply the values you would like
221222
as strings or lists of strings!
222223
223-
>>> pd.read_excel(open('tmp.xlsx','rb'),
224+
>>> pd.read_excel('tmp.xlsx',
224225
... na_values=['string1', 'string2'])
225226
Name Value
226227
0 NaN 1
@@ -298,6 +299,7 @@ def read_excel(io,
298299
parse_dates=False,
299300
date_parser=None,
300301
thousands=None,
302+
comment=None,
301303
skipfooter=0,
302304
convert_float=True,
303305
**kwds):
@@ -331,12 +333,8 @@ def read_excel(io,
331333
parse_dates=parse_dates,
332334
date_parser=date_parser,
333335
thousands=thousands,
334-
<<<<<<< cc8a5c2681bfc6e209968ff9eb801e55454dfead
335-
skipfooter=skipfooter,
336-
=======
337336
comment=comment,
338-
skip_footer=skip_footer,
339-
>>>>>>> changed order of arguments
337+
skipfooter=skipfooter,
340338
convert_float=convert_float,
341339
**kwds)
342340

@@ -418,12 +416,8 @@ def parse(self,
418416
parse_dates=False,
419417
date_parser=None,
420418
thousands=None,
421-
<<<<<<< cc8a5c2681bfc6e209968ff9eb801e55454dfead
422-
skipfooter=0,
423-
=======
424419
comment=None,
425-
skip_footer=0,
426-
>>>>>>> changed order of arguments
420+
skipfooter=0,
427421
convert_float=True,
428422
**kwds):
429423
"""
@@ -448,12 +442,8 @@ def parse(self,
448442
parse_dates=parse_dates,
449443
date_parser=date_parser,
450444
thousands=thousands,
451-
<<<<<<< cc8a5c2681bfc6e209968ff9eb801e55454dfead
452-
skipfooter=skipfooter,
453-
=======
454445
comment=comment,
455-
skip_footer=skip_footer,
456-
>>>>>>> changed order of arguments
446+
skipfooter=skipfooter,
457447
convert_float=convert_float,
458448
**kwds)
459449

@@ -507,12 +497,8 @@ def _parse_excel(self,
507497
parse_dates=False,
508498
date_parser=None,
509499
thousands=None,
510-
<<<<<<< cc8a5c2681bfc6e209968ff9eb801e55454dfead
511-
skipfooter=0,
512-
=======
513500
comment=None,
514-
skip_footer=0,
515-
>>>>>>> changed order of arguments
501+
skipfooter=0,
516502
convert_float=True,
517503
**kwds):
518504

@@ -686,12 +672,8 @@ def _parse_cell(cell_contents, cell_typ):
686672
parse_dates=parse_dates,
687673
date_parser=date_parser,
688674
thousands=thousands,
689-
<<<<<<< cc8a5c2681bfc6e209968ff9eb801e55454dfead
690-
skipfooter=skipfooter,
691-
=======
692675
comment=comment,
693-
skipfooter=skip_footer,
694-
>>>>>>> changed order of arguments
676+
skipfooter=skipfooter,
695677
**kwds)
696678

697679
output[asheetname] = parser.read(nrows=nrows)

0 commit comments

Comments
 (0)