Skip to content

Commit

Permalink
BUG: fix data borking in to_datetime called on Series with datetime64…
Browse files Browse the repository at this point in the history
… values already. close #2699
  • Loading branch information
wesm committed Jan 19, 2013
1 parent d19c205 commit 03bee8d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions RELEASE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ pandas 0.10.1
- Fix a Cython C int64 boxing issue causing read_csv to return incorrect
results (GH2599_)
- Fix groupby summing performance issue on boolean data (GH2692_)
- Don't bork Series containing datetime64 values with to_datetime (GH2699_)

**API Changes**

Expand All @@ -103,6 +104,7 @@ pandas 0.10.1
.. _GH2637: https://github.com/pydata/pandas/issues/2637
.. _GH2690: https://github.com/pydata/pandas/issues/2690
.. _GH2692: https://github.com/pydata/pandas/issues/2692
.. _GH2699: https://github.com/pydata/pandas/issues/2699

pandas 0.10.0
=============
Expand Down
7 changes: 7 additions & 0 deletions pandas/tseries/tests/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,13 @@ def test_to_datetime_default(self):
xp = datetime(2001, 1, 1)
self.assert_(rs, xp)

def test_to_datetime_on_datetime64_series(self):
# #2699
s = Series(date_range('1/1/2000', periods=10))

result = to_datetime(s)
self.assertEquals(result[0], s[0])

def test_nat_vector_field_access(self):
idx = DatetimeIndex(['1/1/2000', None, None, '1/4/2000'])

Expand Down
4 changes: 3 additions & 1 deletion pandas/tseries/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ def _convert_f(arg):
elif isinstance(arg, datetime):
return arg
elif isinstance(arg, Series):
values = _convert_f(arg.values)
values = arg.values
if not com.is_datetime64_dtype(values):
values = _convert_f(values)
return Series(values, index=arg.index, name=arg.name)
elif isinstance(arg, (np.ndarray, list)):
if isinstance(arg, list):
Expand Down

0 comments on commit 03bee8d

Please sign in to comment.