Skip to content

Commit

Permalink
DEPR: Deprecate DateRange [fix pandas-dev#6816]
Browse files Browse the repository at this point in the history
  • Loading branch information
jsexauer committed Apr 6, 2014
1 parent fe9aa12 commit 1cfe934
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 79 deletions.
1 change: 0 additions & 1 deletion pandas/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
48 changes: 0 additions & 48 deletions pandas/core/daterange.py

This file was deleted.

20 changes: 0 additions & 20 deletions pandas/core/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions pandas/core/internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
3 changes: 1 addition & 2 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion pandas/tseries/tests/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions pandas/tseries/tests/test_timeseries_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down
1 change: 0 additions & 1 deletion pandas/tseries/tests/test_timezones.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1cfe934

Please sign in to comment.