Skip to content

DatetimeIndex constructor is inconsistent #1769

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

Closed
mcobzarenco opened this issue Aug 15, 2012 · 0 comments
Closed

DatetimeIndex constructor is inconsistent #1769

mcobzarenco opened this issue Aug 15, 2012 · 0 comments

Comments

@mcobzarenco
Copy link

It would be really neat if the DatetimeIndex constructor took an argument "dayfirst" which would force it to interpret a date as DD-MM-YYYY or similar when presented with a sequence of strings.

What it should never do is assume different formats for different strings in the same sequence (the current behaviour):

  • If the string can be interpreted as a "month first" date, i.e. <= 12 it's parsed this way
  • Otherwise it's parse as a day first string

I.e. all strings in the sequence for which the day happens to be <= 12 are parsed as "month first" and the rest as "day first".

pandas.DatetimeIndex(['12/05/2007', '25/01/2008'])

<class 'pandas.tseries.index.DatetimeIndex'>
[2007-12-05 00:00:00, 2008-01-25 00:00:00]
Length: 2, Freq: None, Timezone: None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants