-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
add try / except to address issue #10154 to_datetime, Inconsistent be… #10216
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
Changes from 3 commits
c35860d
f3dd848
b4ef19d
9b23e5c
7327f6b
3d54fe7
80597dc
0859e07
9da54ad
d670fc7
2bd978f
e4e72c2
d0b63e5
e43b721
7153e6a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
import nose | ||
from numpy import nan | ||
import numpy as np | ||
from pandas import Index, isnull, Timestamp | ||
from pandas import Index, isnull, Timestamp, to_datetime, NaT | ||
from pandas.util.testing import assert_almost_equal | ||
import pandas.util.testing as tm | ||
from pandas.compat import range, lrange, zip | ||
|
@@ -737,6 +737,17 @@ def test_get_period_field_raises_on_out_of_range(self): | |
def test_get_period_field_array_raises_on_out_of_range(self): | ||
self.assertRaises(ValueError, period.get_period_field_arr, -1, np.empty(1), 0) | ||
|
||
class TestDaysInMonth(tm.TestCase): | ||
def test_day_not_in_month_coerce_true(self): | ||
self.assertTrue(isnull(to_datetime('2015-02-29', coerce=True))) | ||
self.assertTrue(isnull(to_datetime('2015-02-29', format="%Y-%m-%d", coerce=True))) | ||
self.assertTrue(isnull(to_datetime('2015-02-32', format="%Y-%m-%d", coerce=True))) | ||
self.assertTrue(isnull(to_datetime('2015-04-31', format="%Y-%m-%d", coerce=True))) | ||
def test_day_not_in_month_coerce_false(self): | ||
self.assertRaises(ValueError, to_datetime, '2015-02-29', format="%Y-%m-%d", coerce=False) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeh, test both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks correct
I would expect the same from this but get a ValueError.
adding format="%Y-%m-%d" should not change the output. |
||
self.assertRaises(ValueError, to_datetime, '2015-02-32', format="%Y-%m-%d", coerce=False) | ||
self.assertRaises(ValueError, to_datetime, '2015-04-31', format="%Y-%m-%d", coerce=False) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add off these cases again, but with |
||
if __name__ == '__main__': | ||
import nose | ||
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'], | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls add the issue number as a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought I did, not sure what went wrong.