Skip to content

Commit 62d8d32

Browse files
jsexauerjreback
authored andcommitted
DEPR: Deprecate DateRange [fix #6816]
1 parent 0cc3677 commit 62d8d32

23 files changed

+25
-115
lines changed

bench/bench_dense_to_sparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
K = 100
44
N = 100000
5-
rng = DateRange('1/1/2000', periods=N, offset=datetools.Minute())
5+
rng = DatetimeIndex('1/1/2000', periods=N, offset=datetools.Minute())
66

77
rng2 = np.asarray(rng).astype('M8[us]').astype('i8')
88

bench/io_roundtrip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import la
77
import pandas
88
from pandas.compat import range
9-
from pandas import datetools, DateRange
9+
from pandas import datetools, DatetimeIndex
1010

1111

1212
def timeit(f, iterations):
@@ -23,7 +23,7 @@ def rountrip_archive(N, K=50, iterations=10):
2323
arr = np.random.randn(N, K)
2424
# lar = la.larry(arr)
2525
dma = pandas.DataFrame(arr,
26-
DateRange('1/1/2000', periods=N,
26+
DatetimeIndex('1/1/2000', periods=N,
2727
offset=datetools.Minute()))
2828
dma[201] = 'bar'
2929

doc/source/release.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ Deprecations
193193
Prior Version Deprecations/Changes
194194
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
195195

196+
- Remove :class:`DateRange` in favor of :class:`DatetimeIndex` (:issue:`6816`)
197+
196198
- Remove ``column`` keyword from ``DataFrame.sort`` (:issue:`4370`)
197199

198200
- Remove ``precision`` keyword from :func:`set_eng_float_format` (:issue:`6641`)

doc/source/v0.14.0.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ Prior Version Deprecations/Changes
353353

354354
There are prior version deprecations that are taking effect as of 0.14.0.
355355

356+
- Remove :class:`DateRange` in favor of :class:`DatetimeIndex` (:issue:`6816`)
357+
356358
- Remove ``column`` keyword from ``DataFrame.sort`` (:issue:`4370`)
357359

358360
- Remove ``precision`` keyword from :func:`set_eng_float_format` (:issue:`6641`)

examples/regressions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
import numpy as np
55

6-
from pandas.core.api import Series, DataFrame, DateRange
6+
from pandas.core.api import Series, DataFrame, DatetimeIndex
77
from pandas.stats.api import ols
88

99
N = 100
1010

1111
start = datetime(2009, 9, 2)
12-
dateRange = DateRange(start, periods=N)
12+
dateRange = DatetimeIndex(start, periods=N)
1313

1414

1515
def makeDataFrame():

pandas/core/api.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
from pandas.tseries.period import Period, PeriodIndex
2929

3030
# legacy
31-
from pandas.core.daterange import DateRange # deprecated
3231
from pandas.core.common import save, load # deprecated, remove in 0.13
3332
import pandas.core.datetools as datetools
3433

pandas/core/daterange.py

Lines changed: 0 additions & 48 deletions
This file was deleted.

pandas/core/index.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3876,26 +3876,6 @@ def _sanitize_and_check(indexes):
38763876
return indexes, 'array'
38773877

38783878

3879-
def _handle_legacy_indexes(indexes):
3880-
from pandas.core.daterange import DateRange
3881-
from pandas.tseries.index import DatetimeIndex
3882-
3883-
converted = []
3884-
for index in indexes:
3885-
if isinstance(index, DateRange):
3886-
if len(index) == 0:
3887-
kwds = dict(data=[], freq=index.offset, tz=index.tzinfo)
3888-
else:
3889-
kwds = dict(start=index[0], end=index[-1],
3890-
freq=index.offset, tz=index.tzinfo)
3891-
3892-
index = DatetimeIndex(**kwds)
3893-
3894-
converted.append(index)
3895-
3896-
return converted
3897-
3898-
38993879
def _get_consensus_names(indexes):
39003880

39013881
# find the non-none names, need to tupleify to make

pandas/core/internals.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
_NS_DTYPE, _TD_DTYPE, ABCSeries, is_list_like,
1313
ABCSparseSeries, _infer_dtype_from_scalar,
1414
_values_from_object, _is_null_datelike_scalar)
15-
from pandas.core.index import (Index, MultiIndex, _ensure_index,
16-
_handle_legacy_indexes)
15+
from pandas.core.index import Index, MultiIndex, _ensure_index
1716
from pandas.core.indexing import (_maybe_convert_indices, _length_of_indexer)
1817
import pandas.core.common as com
1918
from pandas.sparse.array import _maybe_to_sparse, SparseArray
@@ -2369,7 +2368,6 @@ def __setstate__(self, state):
23692368
ax_arrays, bvalues, bitems = state[:3]
23702369

23712370
self.axes = [_ensure_index(ax) for ax in ax_arrays]
2372-
self.axes = _handle_legacy_indexes(self.axes)
23732371

23742372
blocks = []
23752373
for values, items in zip(bvalues, bitems):

pandas/core/series.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
_ensure_object, SettingWithCopyError)
2727

2828
from pandas.core.index import (Index, MultiIndex, InvalidIndexError,
29-
_ensure_index, _handle_legacy_indexes)
29+
_ensure_index)
3030
from pandas.core.indexing import (
3131
_check_bool_indexer,
3232
_is_index_slice, _maybe_convert_indices)
@@ -426,7 +426,6 @@ def _unpickle_series_compat(self, state):
426426
index, name = own_state[0], None
427427
if len(own_state) > 1:
428428
name = own_state[1]
429-
index = _handle_legacy_indexes([index])[0]
430429

431430
# recreate
432431
self._data = SingleBlockManager(data, index, fastpath=True)

0 commit comments

Comments
 (0)