Skip to content

DOC: failing example in the read_csv docs #23954

Closed
@jorisvandenbossche

Description

@jorisvandenbossche

On the travis build on master, we have the following traceback:

>>>-------------------------------------------------------------------------
Exception in /home/travis/build/pandas-dev/pandas/doc/source/io.rst at block ending on line 668
Specify :okexcept: as an option in the ipython:: block to suppress this message
---------------------------------------------------------------------------
EmptyDataError                            Traceback (most recent call last)
<ipython-input-70-2ad3ec79b56f> in <module>
----> 1 pd.read_csv(StringIO(data), comment='#', skiprows=4, header=1)
~/build/pandas-dev/pandas/pandas/io/parsers.py in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, warn_bad_lines, delim_whitespace, low_memory, memory_map, float_precision)
    694                     skip_blank_lines=skip_blank_lines)
    695 
--> 696         return _read(filepath_or_buffer, kwds)
    697 
    698     parser_f.__name__ = name
~/build/pandas-dev/pandas/pandas/io/parsers.py in _read(filepath_or_buffer, kwds)
    421 
    422     # Create the parser.
--> 423     parser = TextFileReader(filepath_or_buffer, **kwds)
    424 
    425     if chunksize or iterator:
~/build/pandas-dev/pandas/pandas/io/parsers.py in __init__(self, f, engine, **kwds)
    887             self.options['has_index_names'] = kwds['has_index_names']
    888 
--> 889         self._make_engine(self.engine)
    890 
    891     def close(self):
~/build/pandas-dev/pandas/pandas/io/parsers.py in _make_engine(self, engine)
   1114     def _make_engine(self, engine='c'):
   1115         if engine == 'c':
-> 1116             self._engine = CParserWrapper(self.f, **self.options)
   1117         else:
   1118             if engine == 'python':
~/build/pandas-dev/pandas/pandas/io/parsers.py in __init__(self, src, **kwds)
   1804         kwds['usecols'] = self.usecols
   1805 
-> 1806         self._reader = parsers.TextReader(src, **kwds)
   1807         self.unnamed_cols = self._reader.unnamed_cols
   1808 
~/build/pandas-dev/pandas/pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader.__cinit__()
EmptyDataError: No columns to parse from file
<<<-------------------------------------------------------------------------

It's failing on this example:

data = '# empty\n# second empty line\n# third empty' \
        'line\nX,Y,Z\n1,2,3\nA,B,C\n1,2.,4.\n5.,NaN,10.0'
print(data)
pd.read_csv(StringIO(data), comment='#', skiprows=4, header=1)

Failing in the dev docs (second example in the warning box): http://pandas-docs.github.io/pandas-docs-travis/io.html#ignoring-line-comments-and-empty-lines
Working find in stable docs: http://pandas.pydata.org/pandas-docs/stable/io.html#ignoring-line-comments-and-empty-lines

Not directly sure why this is failing, it might also be something sphinx/ipython related, and not necessarily a regression in read_csv.

cc @gfyoung

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions