-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
REGR: to_datetime with non-ISO format, float, and nan fails on main #50238
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 all commits
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -135,6 +135,17 @@ def test_to_datetime_format_YYYYMMDD_with_nat(self, cache): | |||||||||||||||||||||||||||||||||||||||||||||||||||
result = to_datetime(ser2, format="%Y%m%d", cache=cache) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
tm.assert_series_equal(result, expected) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
def test_to_datetime_format_YYYYMM_with_nat(self, cache): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
# https://github.com/pandas-dev/pandas/issues/50237 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ser = Series([198012, 198012] + [198101] * 5) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
expected = Series( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
[Timestamp("19801201"), Timestamp("19801201")] + [Timestamp("19810101")] * 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
expected[2] = np.nan | ||||||||||||||||||||||||||||||||||||||||||||||||||||
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. If 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. hey - no, that would hit this branch: pandas/pandas/_libs/tslibs/strptime.pyx Lines 163 to 165 in e8e77c7
, which is covered by a bunch of tests, e.g. pandas/pandas/tests/tools/test_to_datetime.py Lines 168 to 189 in e8e77c7
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
ser[2] = np.nan | ||||||||||||||||||||||||||||||||||||||||||||||||||||
result = to_datetime(ser, format="%Y%m", cache=cache) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
tm.assert_series_equal(result, expected) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
def test_to_datetime_format_YYYYMMDD_ignore(self, cache): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
# coercion | ||||||||||||||||||||||||||||||||||||||||||||||||||||
# GH 7930 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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.
matches
pandas/pandas/_libs/tslib.pyx
Lines 343 to 346 in 6598797