Skip to content

BUG: pd.to_datetime doesn't raises AttributeError with specific input… #13909

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

Merged
merged 1 commit into from
Aug 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.19.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ Bug Fixes
- Bug in ``factorize`` raises ``AmbiguousTimeError`` if data contains datetime near DST boundary (:issue:`13750`)
- Bug in ``.set_index`` raises ``AmbiguousTimeError`` if new index contains DST boundary and multi levels (:issue:`12920`)
- Bug in ``pd.read_hdf()`` returns incorrect result when a ``DataFrame`` with a ``categorical`` column and a query which doesn't match any values (:issue:`13792`)
- Bug in ``pd.to_datetime()`` raise ``AttributeError`` with NaN and the other string is not valid when errors='ignore' (:issue:`12424`)


- Bug in ``Series`` comparison operators when dealing with zero dim NumPy arrays (:issue:`13006`)
Expand Down
6 changes: 6 additions & 0 deletions pandas/tests/test_algos.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,12 @@ def test_value_counts_datetime_outofbounds(self):
exp = pd.Series([3, 2, 1], index=exp_index)
tm.assert_series_equal(res, exp)

# GH 12424
res = pd.to_datetime(pd.Series(['2362-01-01', np.nan]),
errors='ignore')
exp = pd.Series(['2362-01-01', np.nan], dtype=object)
tm.assert_series_equal(res, exp)

def test_categorical(self):
s = Series(pd.Categorical(list('aaabbc')))
result = s.value_counts()
Expand Down
6 changes: 3 additions & 3 deletions pandas/tslib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2396,10 +2396,10 @@ cpdef array_to_datetime(ndarray[object] values, errors='raise',

# set as nan except if its a NaT
if _checknull_with_nat(val):
if val.view('i8') == NPY_NAT:
oresult[i] = NaT
else:
if PyFloat_Check(val):
oresult[i] = np.nan
else:
oresult[i] = NaT
elif util.is_datetime64_object(val):
if get_datetime64_value(val) == NPY_NAT:
oresult[i] = NaT
Expand Down