Skip to content

read_csv: Inconsistent behaviour with parse_dates if the first row is short #11019

Closed
@jmopp

Description

@jmopp

I suspect this is related to #6710.

import pandas
from io import StringIO
t = "a,b,c,d\n1970-01-01,2,3,4"
s2 = "a,b,c\n1970-01-01,2,3\n1980-01-01,2,3,4"
s = "a,b,c\n1970-01-01,2,3,4"
pandas.read_csv(StringIO(t), parse_dates=['a'])
pandas.read_csv(StringIO(s2), parse_dates=['a'])
pandas.read_csv(StringIO(s), parse_dates=['a'])

Calling read_csv with parse_dates=['a'] does the correct thing for t, raises a CParserError for s2, and raises TypeError: 'NoneType' object has no attribute '__getitem__' for s.

I would expect a CParserError for s as well.

Pandas version: 0.16.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Error ReportingIncorrect or improved errors from pandasIO CSVread_csv, to_csvTestingpandas testing functions or related to the test suite

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions