diff --git a/RELEASE.rst b/RELEASE.rst index 11a3fabe06868..171fdbd6ca2c9 100644 --- a/RELEASE.rst +++ b/RELEASE.rst @@ -29,6 +29,7 @@ pandas 0.8.1 **New features** + - Add vectorized, NA-friendly string methods to Series (#1621, #620) - Can pass dict of per-column line styles to DataFrame.plot (#1559) - Add new ``bootstrap_plot`` plot function - Add new ``parallel_coordinates`` plot function (#1488) @@ -82,6 +83,7 @@ pandas 0.8.1 - Fix unit test errors on Python 3 (#1550) - Fix .ix indexing bugs in duplicate DataFrame index (#1201) - Better handle errors with non-existing objects in HDFStore (#1254) + - Don't copy int64 array data in DatetimeIndex when copy=False (#1624) pandas 0.8.0 ============ diff --git a/pandas/tseries/index.py b/pandas/tseries/index.py index 390280bb81725..921a35df528f2 100644 --- a/pandas/tseries/index.py +++ b/pandas/tseries/index.py @@ -208,7 +208,10 @@ def __new__(cls, data=None, else: subarr = data elif data.dtype == _INT64_DTYPE: - subarr = np.asarray(data, dtype=_NS_DTYPE) + if copy: + subarr = np.asarray(data, dtype=_NS_DTYPE) + else: + subarr = data.view(_NS_DTYPE) else: subarr = tools.to_datetime(data) if not np.issubdtype(subarr.dtype, np.datetime64): diff --git a/pandas/tseries/tests/test_timeseries.py b/pandas/tseries/tests/test_timeseries.py index 59ec0650f323f..a6bbeb1e7c40c 100644 --- a/pandas/tseries/tests/test_timeseries.py +++ b/pandas/tseries/tests/test_timeseries.py @@ -1012,6 +1012,19 @@ def test_datetimeindex_repr_short(self): dr = date_range(start='1/1/2012', periods=3) repr(dr) + def test_constructor_int64_nocopy(self): + # #1624 + arr = np.arange(1000) + index = DatetimeIndex(arr) + + arr[50:100] = -1 + self.assert_((index.asi8[50:100] == -1).all()) + + arr = np.arange(1000) + index = DatetimeIndex(arr, copy=True) + + arr[50:100] = -1 + self.assert_((index.asi8[50:100] != -1).all()) def _simple_ts(start, end, freq='D'): rng = date_range(start, end, freq=freq)