-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
make easier to parse european-style dates in to_csv #854
Comments
Sometimes, there are also separators such as ".", "-" but I assume this doesn't play a role in here. |
Do you want us to supply more date formats as examples to enhance the parser? |
@timmie, absolutely, any examples you want supported would be great |
Here are some commonly encountered formats:
|
Often I also see that instead of using hour numbers from 0-23 (like Python datetime) some use 1-24 for storage:
The reason is that people what to show with this that the value belongs to the end of the described data interval and not the beginning or middle. |
Is #854 (comment) an extra issue? |
see also #1296 |
Again from mailing list:
Example:
data1 = '''date;value
01/05/2010;1
15/05/2010;2
31/05/2010;3
'''
df = pd.read_csv(StringIO(data1),sep=";",converters={'date':pd.datetools.dateutil.parser.parse})
print df.to_string()
Returns the first row wrong:
date value
0 2010-01-05 00:00:00 1
1 2010-05-15 00:00:00 2
2 2010-05-31 00:00:00 3
df = pd.read_csv(StringIO(data1),sep=";",converters={'date':lambda x: pd.datetools.dateutil.parser.parse(x, dayfirst=True)})
print df.to_string()
Returns the correct output
date value
0 2010-05-01 00:00:00 1
1 2010-05-15 00:00:00 2
2 2010-05-31 00:00:00 3
When using index_col and parse_dates, you can get also some of the dates that are wrong, some of them correct.
df = pd.read_csv(StringIO(data1),sep=";",index_col=[0],parse_dates=True)
print df.to_string()
Returns the first line also wrong:
value
date
2010-01-05 1
2010-05-15 2
2010-05-31 3
The text was updated successfully, but these errors were encountered: