From 29fe3954a82ac6ac512762afb2fd876853048291 Mon Sep 17 00:00:00 2001 From: jreback Date: Sat, 23 Mar 2013 12:32:58 -0400 Subject: [PATCH] BUG: GH3094, timedelta64 failing on numpy 1.7.0 (on 2.7) as np.array(td series) converts to int64 dtype --- RELEASE.rst | 3 ++- pandas/core/series.py | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/RELEASE.rst b/RELEASE.rst index 14619cbed110a..eb2d30ca3e448 100644 --- a/RELEASE.rst +++ b/RELEASE.rst @@ -179,7 +179,7 @@ pandas 0.11.0 - Series ops with a Timestamp on the rhs was throwing an exception (GH2898_) added tests for Series ops with datetimes,timedeltas,Timestamps, and datelike Series on both lhs and rhs - - Fixed subtle timedelta64 inference issue on py3 + - Fixed subtle timedelta64 inference issue on py3 & numpy 1.7.0 (GH3094_) - Fixed some formatting issues on timedelta when negative - Support null checking on timedelta64, representing (and formatting) with NaT - Support setitem with np.nan value, converts to NaT @@ -293,6 +293,7 @@ pandas 0.11.0 .. _GH3115: https://github.com/pydata/pandas/issues/3115 .. _GH3070: https://github.com/pydata/pandas/issues/3070 .. _GH3075: https://github.com/pydata/pandas/issues/3075 +.. _GH3094: https://github.com/pydata/pandas/issues/3094 .. _GH3130: https://github.com/pydata/pandas/issues/3130 pandas 0.10.1 diff --git a/pandas/core/series.py b/pandas/core/series.py index 6efa4026641c0..35448d26e4fd5 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -104,6 +104,11 @@ def convert_to_array(values): pass else: values = com._possibly_cast_to_timedelta(values) + elif inferred_type in set(['integer']): + if values.dtype == 'timedelta64[ns]': + pass + elif values.dtype.kind == 'm': + values = values.astype('timedelta64[ns]') else: values = pa.array(values) return values