diff --git a/pandas/core/api.py b/pandas/core/api.py index 3ebcb46cd98fa..b7e02917cd476 100644 --- a/pandas/core/api.py +++ b/pandas/core/api.py @@ -28,7 +28,6 @@ from pandas.tseries.period import Period, PeriodIndex # legacy -from pandas.core.daterange import DateRange # deprecated from pandas.core.common import save, load # deprecated, remove in 0.13 import pandas.core.datetools as datetools diff --git a/pandas/core/daterange.py b/pandas/core/daterange.py deleted file mode 100644 index bdaf546789c39..0000000000000 --- a/pandas/core/daterange.py +++ /dev/null @@ -1,48 +0,0 @@ -# pylint: disable=E1101,E1103 - -from pandas.core.index import Index -from pandas.tseries.index import DatetimeIndex -import pandas.core.datetools as datetools - - -#----------------------------------------------------------------------------- -# DateRange class - -class DateRange(Index): - - """Deprecated - """ - - offset = tzinfo = None - - def __new__(cls, start=None, end=None, periods=None, - offset=datetools.bday, time_rule=None, - tzinfo=None, name=None, **kwds): - - import warnings - warnings.warn("DateRange is deprecated, use DatetimeIndex instead", - FutureWarning) - - if time_rule is None: - time_rule = kwds.get('timeRule') - if time_rule is not None: - offset = datetools.get_offset(time_rule) - - return DatetimeIndex(start=start, end=end, - periods=periods, freq=offset, - tzinfo=tzinfo, name=name, **kwds) - - def __setstate__(self, aug_state): - """Necessary for making this object picklable""" - index_state = aug_state[:1] - offset = aug_state[1] - - # for backwards compatibility - if len(aug_state) > 2: - tzinfo = aug_state[2] - else: # pragma: no cover - tzinfo = None - - self.offset = offset - self.tzinfo = tzinfo - Index.__setstate__(self, *index_state) diff --git a/pandas/core/index.py b/pandas/core/index.py index bae4a2c455ec6..c162365a39bf8 100644 --- a/pandas/core/index.py +++ b/pandas/core/index.py @@ -3888,26 +3888,6 @@ def _sanitize_and_check(indexes): return indexes, 'array' -def _handle_legacy_indexes(indexes): - from pandas.core.daterange import DateRange - from pandas.tseries.index import DatetimeIndex - - converted = [] - for index in indexes: - if isinstance(index, DateRange): - if len(index) == 0: - kwds = dict(data=[], freq=index.offset, tz=index.tzinfo) - else: - kwds = dict(start=index[0], end=index[-1], - freq=index.offset, tz=index.tzinfo) - - index = DatetimeIndex(**kwds) - - converted.append(index) - - return converted - - def _get_consensus_names(indexes): # find the non-none names, need to tupleify to make diff --git a/pandas/core/internals.py b/pandas/core/internals.py index e28d4029d4fa0..0560480a9c2db 100644 --- a/pandas/core/internals.py +++ b/pandas/core/internals.py @@ -12,8 +12,7 @@ _NS_DTYPE, _TD_DTYPE, ABCSeries, is_list_like, ABCSparseSeries, _infer_dtype_from_scalar, _values_from_object, _is_null_datelike_scalar) -from pandas.core.index import (Index, MultiIndex, _ensure_index, - _handle_legacy_indexes) +from pandas.core.index import Index, MultiIndex, _ensure_index from pandas.core.indexing import (_maybe_convert_indices, _length_of_indexer) import pandas.core.common as com from pandas.sparse.array import _maybe_to_sparse, SparseArray @@ -2369,7 +2368,6 @@ def __setstate__(self, state): ax_arrays, bvalues, bitems = state[:3] self.axes = [_ensure_index(ax) for ax in ax_arrays] - self.axes = _handle_legacy_indexes(self.axes) blocks = [] for values, items in zip(bvalues, bitems): diff --git a/pandas/core/series.py b/pandas/core/series.py index 4ab7855ec2f84..763d14b629508 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -26,7 +26,7 @@ _ensure_object, SettingWithCopyError) from pandas.core.index import (Index, MultiIndex, InvalidIndexError, - _ensure_index, _handle_legacy_indexes) + _ensure_index) from pandas.core.indexing import ( _check_bool_indexer, _is_index_slice, _maybe_convert_indices) @@ -426,7 +426,6 @@ def _unpickle_series_compat(self, state): index, name = own_state[0], None if len(own_state) > 1: name = own_state[1] - index = _handle_legacy_indexes([index])[0] # recreate self._data = SingleBlockManager(data, index, fastpath=True) diff --git a/pandas/tseries/tests/test_timeseries.py b/pandas/tseries/tests/test_timeseries.py index 64da6f76f3697..1bcf6c0b4431a 100644 --- a/pandas/tseries/tests/test_timeseries.py +++ b/pandas/tseries/tests/test_timeseries.py @@ -15,7 +15,6 @@ isnull, date_range, Timestamp, Period, DatetimeIndex, Int64Index, to_datetime, bdate_range, Float64Index) -from pandas.core.daterange import DateRange import pandas.core.datetools as datetools import pandas.tseries.offsets as offsets import pandas.tseries.tools as tools diff --git a/pandas/tseries/tests/test_timeseries_legacy.py b/pandas/tseries/tests/test_timeseries_legacy.py index 3155f0f6e1a80..a9e057e9e5fe1 100644 --- a/pandas/tseries/tests/test_timeseries_legacy.py +++ b/pandas/tseries/tests/test_timeseries_legacy.py @@ -13,7 +13,6 @@ isnull, date_range, Timestamp, DatetimeIndex, Int64Index, to_datetime, bdate_range) -from pandas.core.daterange import DateRange import pandas.core.datetools as datetools import pandas.tseries.offsets as offsets import pandas.tseries.frequencies as fmod @@ -285,8 +284,8 @@ def test_inferTimeRule(self): self.assertRaises(Exception, inferTimeRule, index3) def test_time_rule(self): - result = DateRange('1/1/2000', '1/30/2000', time_rule='WEEKDAY') - result2 = DateRange('1/1/2000', '1/30/2000', timeRule='WEEKDAY') + result = DatetimeIndex('1/1/2000', '1/30/2000', time_rule='WEEKDAY') + result2 = DatetimeIndex('1/1/2000', '1/30/2000', timeRule='WEEKDAY') expected = date_range('1/1/2000', '1/30/2000', freq='B') self.assert_(result.equals(expected)) diff --git a/pandas/tseries/tests/test_timezones.py b/pandas/tseries/tests/test_timezones.py index dda722366e53e..245a21eb2c112 100644 --- a/pandas/tseries/tests/test_timezones.py +++ b/pandas/tseries/tests/test_timezones.py @@ -12,7 +12,6 @@ from pandas import DatetimeIndex, Int64Index, to_datetime, NaT -from pandas.core.daterange import DateRange import pandas.core.datetools as datetools import pandas.tseries.offsets as offsets from pandas.tseries.index import bdate_range, date_range