|
53 | 53 | # so we need to remove it if we see it.
|
54 | 54 | _BOM = u('\ufeff')
|
55 | 55 |
|
56 |
| -_parser_params = r"""Also supports optionally iterating or breaking of the file |
| 56 | +_parser_params = r"""{summary} |
| 57 | +
|
| 58 | +Also supports optionally iterating or breaking of the file |
57 | 59 | into chunks.
|
58 | 60 |
|
59 | 61 | Additional help can be found in the `online docs for IO Tools
|
|
71 | 73 |
|
72 | 74 | By file-like object, we refer to objects with a ``read()`` method, such as
|
73 | 75 | a file handler (e.g. via builtin ``open`` function) or ``StringIO``.
|
74 |
| -%s |
| 76 | +{sep_doc} |
75 | 77 | header : int or list of ints, default 'infer'
|
76 | 78 | Row number(s) to use as the column names, and the start of the
|
77 | 79 | data. Default behavior is to infer the column names: if no names
|
|
122 | 124 | 'X'...'X'. Passing in False will cause data to be overwritten if there
|
123 | 125 | are duplicate names in the columns.
|
124 | 126 | dtype : Type name or dict of column -> type, default None
|
125 |
| - Data type for data or columns. E.g. {'a': np.float64, 'b': np.int32} |
| 127 | + Data type for data or columns. E.g. {{'a': np.float64, 'b': np.int32}} |
126 | 128 | Use `str` or `object` together with suitable `na_values` settings
|
127 | 129 | to preserve and not interpret dtype.
|
128 | 130 | If converters are specified, they will be applied INSTEAD
|
129 | 131 | of dtype conversion.
|
130 |
| -%s |
| 132 | +{engine_doc} |
131 | 133 | converters : dict, default None
|
132 | 134 | Dict of functions for converting values in certain columns. Keys can either
|
133 | 135 | be integers or column labels.
|
|
185 | 187 | each as a separate date column.
|
186 | 188 | * list of lists. e.g. If [[1, 3]] -> combine columns 1 and 3 and parse as
|
187 | 189 | a single date column.
|
188 |
| - * dict, e.g. {'foo' : [1, 3]} -> parse columns 1, 3 as date and call result |
189 |
| - 'foo' |
| 190 | + * dict, e.g. {{'foo' : [1, 3]}} -> parse columns 1, 3 as date and call |
| 191 | + result 'foo' |
190 | 192 |
|
191 | 193 | If a column or index contains an unparseable date, the entire column or
|
192 | 194 | index will be returned unaltered as an object data type. For non-standard
|
|
221 | 223 | See the `IO Tools docs
|
222 | 224 | <http://pandas.pydata.org/pandas-docs/stable/io.html#io-chunking>`_
|
223 | 225 | for more information on ``iterator`` and ``chunksize``.
|
224 |
| -compression : {'infer', 'gzip', 'bz2', 'zip', 'xz', None}, default 'infer' |
| 226 | +compression : {{'infer', 'gzip', 'bz2', 'zip', 'xz', None}}, default 'infer' |
225 | 227 | For on-the-fly decompression of on-disk data. If 'infer' and
|
226 | 228 | `filepath_or_buffer` is path-like, then detect compression from the
|
227 | 229 | following extensions: '.gz', '.bz2', '.zip', or '.xz' (otherwise no
|
|
309 | 311 | Returns
|
310 | 312 | -------
|
311 | 313 | DataFrame or TextParser
|
| 314 | + A comma-separated values (csv) file is returned as two-dimensional |
| 315 | + data structure with labeled axes. |
312 | 316 |
|
313 | 317 | See Also
|
314 | 318 | --------
|
315 | 319 | to_csv : Write DataFrame to a comma-separated values (csv) file.
|
316 |
| -%s |
| 320 | +read_csv : Read a comma-separated values (csv) file into DataFrame. |
| 321 | +read_fwf : Read a table of fixed-width formatted lines into DataFrame. |
317 | 322 |
|
318 | 323 | Examples
|
319 | 324 | --------
|
320 |
| -%s # doctest: +SKI""" |
| 325 | +>>> pd.{func_name}('data.csv') # doctest: +SKIP |
| 326 | +""" |
| 327 | + |
| 328 | +# Summary line for read_csv,read_table and read_fwf |
| 329 | +_summary_read_csv = """ |
| 330 | +Read a comma-separated values (csv) file into DataFrame.""" |
| 331 | + |
| 332 | +_summary_read_table = """ |
| 333 | +Read general delimited file into DataFrame. |
| 334 | +
|
| 335 | +.. deprecated:: 0.24.0 |
| 336 | + Use :func:`pandas.read_csv` instead, passing ``sep='\t'`` if necessary.""" |
| 337 | + |
| 338 | +_summary_read_fwf = """ |
| 339 | +Read a table of fixed-width formatted lines into DataFrame.""" |
321 | 340 |
|
322 | 341 | # engine is not used in read_fwf() so is factored out of the shared docstring
|
323 | 342 | _engine_doc = """engine : {'c', 'python'}, optional
|
|
335 | 354 | delimiter : str, default ``None``
|
336 | 355 | Alias for sep.
|
337 | 356 | """
|
338 |
| - |
339 |
| -_see_also_csv_doc = ('read_csv : Read a comma-separated values ' |
340 |
| - '(csv) file into DataFrame.') |
341 |
| - |
342 |
| -_see_also_fwf_doc = ('read_fwf : Read a table of ' |
343 |
| - 'fixed-width formatted lines into DataFrame.') |
344 |
| - |
345 |
| -_example_doc = "pd.{_api}('/tmp/data.csv')" |
346 |
| - |
347 |
| -_read_csv_doc = """ |
348 |
| -Read a comma-separated values (csv) file into DataFrame. |
349 |
| -
|
350 |
| -%s |
351 |
| -""" % (_parser_params % (_sep_doc.format(default="','"), |
352 |
| - _engine_doc, _see_also_fwf_doc, |
353 |
| - _example_doc.format(_api='read_csv'))) |
354 |
| - |
355 |
| -_read_table_doc = """ |
356 |
| -Read general delimited file into DataFrame. |
357 |
| -
|
358 |
| -.. deprecated:: 0.24.0 |
359 |
| - Use :func:`pandas.read_csv` instead, passing ``sep='\t'`` if necessary. |
360 |
| -
|
361 |
| -%s |
362 |
| -""" % (_parser_params % (_sep_doc.format(default="\\t (tab-stop)"), |
363 |
| - _engine_doc, |
364 |
| - '{}\n{}'.format(_see_also_csv_doc, _see_also_fwf_doc), |
365 |
| - _example_doc.format(_api='read_table'))) |
| 357 | +# _read_csv_doc = """ |
| 358 | +# Read a comma-separated values (csv) file into DataFrame. |
| 359 | + |
| 360 | +# %s |
| 361 | +# """ % (_parser_params % (_sep_doc.format(default="','"), |
| 362 | +# _engine_doc, |
| 363 | +# _example_doc.format(_api='read_csv'))) |
| 364 | +_read_csv_doc = (_parser_params |
| 365 | + .format(summary=_summary_read_csv, |
| 366 | + sep_doc=_sep_doc.format(default="','"), |
| 367 | + engine_doc=_engine_doc, |
| 368 | + func_name='read_csv')) |
| 369 | + |
| 370 | +_read_table_doc = (_parser_params |
| 371 | + .format(summary=_summary_read_table, |
| 372 | + sep_doc=_sep_doc.format(default="\\t (tab-stop)"), |
| 373 | + engine_doc=_engine_doc, |
| 374 | + func_name='read_table')) |
366 | 375 |
|
367 | 376 | _fwf_widths = """\
|
368 | 377 | colspecs : list of pairs (int, int) or 'infer'. optional
|
|
380 | 389 | if it is not spaces (e.g., '~').
|
381 | 390 | """
|
382 | 391 |
|
383 |
| -_read_fwf_doc = """ |
384 |
| -Read a table of fixed-width formatted lines into DataFrame. |
385 |
| -
|
386 |
| -%s |
387 |
| -""" % (_parser_params % (_fwf_widths, '', |
388 |
| - _see_also_csv_doc, |
389 |
| - _example_doc.format(_api='read_fwf'))) |
| 392 | +_read_fwf_doc = (_parser_params |
| 393 | + .format(summary=_summary_read_fwf, |
| 394 | + sep_doc='', |
| 395 | + engine_doc='', |
| 396 | + func_name='read_fwf')) |
390 | 397 |
|
391 | 398 |
|
392 | 399 | def _validate_integer(name, val, min_val=0):
|
|
0 commit comments