Skip to content

DatetimeIndex doesn't validate dtype argument #23986

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
TomAugspurger opened this issue Nov 28, 2018 · 3 comments · Fixed by #25931
Closed

DatetimeIndex doesn't validate dtype argument #23986

TomAugspurger opened this issue Nov 28, 2018 · 3 comments · Fixed by #25931
Labels
Datetime Datetime data dtype Error Reporting Incorrect or improved errors from pandas good first issue Needs Tests Unit test(s) needed to prevent regressions

Comments

@TomAugspurger
Copy link
Contributor

In [2]: pd.DatetimeIndex([1, 2], dtype=object())
Out[2]: DatetimeIndex(['1970-01-01 00:00:00.000000001', '1970-01-01 00:00:00.000000002'], dtype='datetime64[ns]', freq=None)

this should probably raise.

@TomAugspurger TomAugspurger added Datetime Datetime data dtype Error Reporting Incorrect or improved errors from pandas Effort Low labels Nov 28, 2018
@TomAugspurger TomAugspurger added this to the Contributions Welcome milestone Nov 28, 2018
@jbrockmendel
Copy link
Member

I’ll work this in to the next PR ( after the current DTA constructor PR goes through). There is a dtype validation step, but it is only checking that conflicting time zones aren’t being passed

@alexcwatt
Copy link
Contributor

I believe this can be closed; @TomAugspurger's example does raise an exception now. The dtype is validated with _validate_dt64_dtype to ensure it is either datetime64[ns] or DatetimeTZDtype.

@mroeschke
Copy link
Member

Probably worthwhile to add a regression test.

@mroeschke mroeschke added good first issue Needs Tests Unit test(s) needed to prevent regressions and removed Effort Low labels Mar 30, 2019
alexcwatt added a commit to alexcwatt/pandas that referenced this issue Mar 30, 2019
alexcwatt added a commit to alexcwatt/pandas that referenced this issue Mar 30, 2019
mroeschke pushed a commit that referenced this issue Mar 31, 2019
* TST: Add regression test for #23986

* Update test name per convention
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Error Reporting Incorrect or improved errors from pandas good first issue Needs Tests Unit test(s) needed to prevent regressions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants