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

BUG date_parser not accurate with Timestamp #2932

Closed
hayd opened this issue Feb 26, 2013 · 0 comments

Comments

@hayd
Copy link
Contributor

commented Feb 26, 2013

When reading in this DataFrame (with parse_dates=[[0,1]]) we see the datetimes have (29000) microseconds but when using date_parser=pd.Timestamp we lose this information:

from StringIO import StringIO
data = """05/31/2012,15:30:00.029,1306.25,1,E,0,,1306.25
05/31/2012,15:30:00.029,1306.25,8,E,0,,1306.25"""
In [3]: pd.read_csv(StringIO(data), sep=',', header=None, parse_dates=[[0,1]])
Out[3]: 
                          0_1        2  3  4  5   6        7
0  2012-05-31 15:30:00.029000  1306.25  1  E  0 NaN  1306.25
1  2012-05-31 15:30:00.029000  1306.25  8  E  0 NaN  1306.25

In [4]: pd.read_csv(StringIO(data), sep=',', header=None, parse_dates=[[0,1]], date_parser=pd.Timestamp)
Out[4]: 
                   0_1        2  3  4  5   6        7
0  2012-05-31 00:00:00  1306.25  1  E  0 NaN  1306.25
1  2012-05-31 00:00:00  1306.25  8  E  0 NaN  1306.25

Note: This works accurately individually:

In [5]: pd.Timestamp('05/31/2012,15:30:00.029')
Out[5]: <Timestamp: 2012-05-31 15:30:00.029000>

Migrated from StackOverflow.

@ghost ghost assigned wesm Mar 28, 2013

@wesm wesm closed this in 94893ff Mar 28, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.