Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jassinm opened this issue Nov 15, 2012 · 2 comments
Closed

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

jassinm opened this issue Nov 15, 2012 · 2 comments
Labels
IO Data IO issues that don't fit into a more specific label
Milestone

Comments

@jassinm
Copy link

jassinm commented Nov 15, 2012

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
@changhiskhan
Copy link
Contributor

I believe this is fixed now on master:

In [2]: import pandas as pd

In [3]: paste
import StringIO
s = StringIO.StringIO("Date, test\n2012-01-01, 1\n,2")
pd.read_csv(s, parse_dates=["Date"])
## -- End pasted text --
Out[3]: 
         Date   test
0  2012-01-01      1
1         nan      2

Can you try updating?

@wesm
Copy link
Member

wesm commented Nov 19, 2012

Note however in a pathological case:

In [12]: pd.read_csv(s, parse_dates=["Date"], na_filter=False)
Out[12]: 
                  Date   test
0  2012-01-01 00:00:00      1
1  2012-11-18 00:00:00      2

I'm as yet unconvinced about being beholden to dateutil's wonkiness, but maybe not so bad.

@wesm wesm closed this as completed in 808c30c Nov 28, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO Data IO issues that don't fit into a more specific label
Projects
None yet
Development

No branches or pull requests

3 participants