Skip to content

read_csv dateparser empty date's are assigned today's date #2263

Closed
@jassinm

Description

@jassinm

Hi,

import StringIO
s = StringIO.StringIO("Date, test\n2012-01-01, 1\n,2")
pd.read_csv(s, parse_dates=["Date"])


    Date     test
0    2012-01-01 00:00:00     1
1    2012-11-15 00:00:00     2

second row should be None.

is this the default behaviour?
this is a quick fix for me

from dateutil.parser import parse as dateparser
def parse_date(d):
    if d.strip():
        return dateparser(d)

pd.read_csv(s, parse_dates=["Date"], date_parser=parse_date)


using pandas 0.9.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    IO DataIO issues that don't fit into a more specific label

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions