Skip to content

Commit 692e67a

Browse files
committed
fix pd.read_csv|read_table|read_fwf
1 parent e7d3b09 commit 692e67a

File tree

1 file changed

+26
-29
lines changed

1 file changed

+26
-29
lines changed

pandas/io/parsers.py

+26-29
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,6 @@
7272
By file-like object, we refer to objects with a ``read()`` method, such as
7373
a file handler (e.g. via builtin ``open`` function) or ``StringIO``.
7474
%s
75-
delim_whitespace : bool, default False
76-
Specifies whether or not whitespace (e.g. ``' '`` or ``'\t'``) will be
77-
used as the sep. Equivalent to setting ``sep='\s+'``. If this option
78-
is set to True, nothing should be passed in for the ``delimiter``
79-
parameter.
80-
81-
.. versionadded:: 0.18.1 support for the Python parser.
82-
8375
header : int or list of ints, default 'infer'
8476
Row number(s) to use as the column names, and the start of the
8577
data. Default behavior is to infer the column names: if no names
@@ -242,11 +234,6 @@
242234
Thousands separator.
243235
decimal : str, default '.'
244236
Character to recognize as decimal point (e.g. use ',' for European data).
245-
float_precision : str, default None
246-
Specifies which converter the C engine should use for floating-point
247-
values. The options are `None` for the ordinary converter,
248-
`high` for the high-precision converter, and `round_trip` for the
249-
round-trip converter.
250237
lineterminator : str (length 1), default None
251238
Character to break file into lines. Only valid with C parser.
252239
quotechar : str (length 1), optional
@@ -280,11 +267,11 @@
280267
override values, a ParserWarning will be issued. See csv.Dialect
281268
documentation for more details.
282269
tupleize_cols : bool, default False
270+
Leave a list of tuples on columns as is (default is to convert to
271+
a MultiIndex on the columns).
283272
.. deprecated:: 0.21.0
284273
This argument will be removed and will always convert to MultiIndex
285274
286-
Leave a list of tuples on columns as is (default is to convert to
287-
a MultiIndex on the columns).
288275
error_bad_lines : bool, default True
289276
Lines with too many fields (e.g. a csv line with too many commas) will by
290277
default cause an exception to be raised, and no DataFrame will be returned.
@@ -293,6 +280,14 @@
293280
warn_bad_lines : bool, default True
294281
If error_bad_lines is False, and warn_bad_lines is True, a warning for each
295282
"bad line" will be output.
283+
delim_whitespace : bool, default False
284+
Specifies whether or not whitespace (e.g. ``' '`` or ``'\t'``) will be
285+
used as the sep. Equivalent to setting ``sep='\s+'``. If this option
286+
is set to True, nothing should be passed in for the ``delimiter``
287+
parameter.
288+
289+
.. versionadded:: 0.18.1 support for the Python parser.
290+
296291
low_memory : bool, default True
297292
Internally process the file in chunks, resulting in lower memory use
298293
while parsing, but possibly mixed type inference. To ensure no mixed
@@ -304,11 +299,15 @@
304299
If a filepath is provided for `filepath_or_buffer`, map the file object
305300
directly onto memory and access the data directly from there. Using this
306301
option can improve performance because there is no longer any I/O overhead.
302+
float_precision : str, default None
303+
Specifies which converter the C engine should use for floating-point
304+
values. The options are `None` for the ordinary converter,
305+
`high` for the high-precision converter, and `round_trip` for the
306+
round-trip converter.
307307
308308
Returns
309309
-------
310-
result : DataFrame or TextParser
311-
"""
310+
result : DataFrame or TextParser"""
312311

313312
# engine is not used in read_fwf() so is factored out of the shared docstring
314313
_engine_doc = """engine : {'c', 'python'}, optional
@@ -334,12 +333,11 @@
334333
""" % (_parser_params % (_sep_doc.format(default="','"), _engine_doc))
335334

336335
_read_table_doc = """
336+
Read general delimited file into DataFrame.
337337
338338
.. deprecated:: 0.24.0
339339
Use :func:`pandas.read_csv` instead, passing ``sep='\t'`` if necessary.
340340
341-
Read general delimited file into DataFrame
342-
343341
%s
344342
""" % (_parser_params % (_sep_doc.format(default="\\t (tab-stop)"),
345343
_engine_doc))
@@ -361,7 +359,7 @@
361359
"""
362360

363361
_read_fwf_doc = """
364-
Read a table of fixed-width formatted lines into DataFrame
362+
Read a table of fixed-width formatted lines into DataFrame.
365363
366364
%s
367365
""" % (_parser_params % (_fwf_widths, ''))
@@ -471,10 +469,10 @@ def _read(filepath_or_buffer, kwds):
471469
_parser_defaults = {
472470
'delimiter': None,
473471

474-
'doublequote': True,
475472
'escapechar': None,
476473
'quotechar': '"',
477474
'quoting': csv.QUOTE_MINIMAL,
475+
'doublequote': True,
478476
'skipinitialspace': False,
479477
'lineterminator': None,
480478

@@ -483,14 +481,16 @@ def _read(filepath_or_buffer, kwds):
483481
'names': None,
484482
'prefix': None,
485483
'skiprows': None,
484+
'skipfooter': 0,
485+
'nrows': None,
486486
'na_values': None,
487+
'keep_default_na': True,
488+
487489
'true_values': None,
488490
'false_values': None,
489491
'converters': None,
490492
'dtype': None,
491-
'skipfooter': 0,
492493

493-
'keep_default_na': True,
494494
'thousands': None,
495495
'comment': None,
496496
'decimal': b'.',
@@ -500,10 +500,8 @@ def _read(filepath_or_buffer, kwds):
500500
'keep_date_col': False,
501501
'dayfirst': False,
502502
'date_parser': None,
503-
504503
'usecols': None,
505504

506-
'nrows': None,
507505
# 'iterator': False,
508506
'chunksize': None,
509507
'verbose': False,
@@ -576,6 +574,7 @@ def parser_f(filepath_or_buffer,
576574
false_values=None,
577575
skipinitialspace=False,
578576
skiprows=None,
577+
skipfooter=0,
579578
nrows=None,
580579

581580
# NA and Missing Data Handling
@@ -603,6 +602,7 @@ def parser_f(filepath_or_buffer,
603602
lineterminator=None,
604603
quotechar='"',
605604
quoting=csv.QUOTE_MINIMAL,
605+
doublequote=True,
606606
escapechar=None,
607607
comment=None,
608608
encoding=None,
@@ -613,10 +613,7 @@ def parser_f(filepath_or_buffer,
613613
error_bad_lines=True,
614614
warn_bad_lines=True,
615615

616-
skipfooter=0,
617-
618616
# Internal
619-
doublequote=True,
620617
delim_whitespace=False,
621618
low_memory=_c_parser_defaults['low_memory'],
622619
memory_map=False,
@@ -668,6 +665,7 @@ def parser_f(filepath_or_buffer,
668665
names=names,
669666
prefix=prefix,
670667
skiprows=skiprows,
668+
skipfooter=skipfooter,
671669
na_values=na_values,
672670
true_values=true_values,
673671
false_values=false_values,
@@ -684,7 +682,6 @@ def parser_f(filepath_or_buffer,
684682
nrows=nrows,
685683
iterator=iterator,
686684
chunksize=chunksize,
687-
skipfooter=skipfooter,
688685
converters=converters,
689686
dtype=dtype,
690687
usecols=usecols,

0 commit comments

Comments
 (0)