Skip to content

BUG: read_table with full line comment and delim_whitespace=True #8115

Closed
@jmkuhn

Description

@jmkuhn

I expect the following to produce a DataFrame with 3 rows, 5 columns and no NaNs. Instead it produces 5 rows with the comment lines filled with NaNs. Pandas version 0.14.1.

In [2]: !cat test.txt
# comment
 0  1  2  3  4
 5  6  7  8  9
# comment
10 11 12 13 15

In [3]: df = pd.read_table("test.txt", skipinitialspace=True,
   ...: names=["A", "B", "C", "D", "E"], delim_whitespace=True, comment="#")

In [4]: df
Out[4]: 
    A   B   C   D   E
0 NaN NaN NaN NaN NaN
1   0   1   2   3   4
2   5   6   7   8   9
3 NaN NaN NaN NaN NaN
4  10  11  12  13  15

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