Skip to content

Commit

Permalink
DEPR: remove legacy pd.TimeSeries class in favor of pd.Series
Browse files Browse the repository at this point in the history
xref pandas-dev#10890

DEPR: remove Series.is_time_series in favor of Series.index.is_all_dates
  • Loading branch information
jreback committed Jan 10, 2017
1 parent aa03e7f commit 6adcf80
Show file tree
Hide file tree
Showing 20 changed files with 13 additions and 64 deletions.
13 changes: 11 additions & 2 deletions doc/source/whatsnew/v0.20.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ Other enhancements
Backwards incompatible API changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. _whatsnew.api_breaking.io_compat

Pickle and HDF5 compat requires >= 0.13.0
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

``pd.TimeSeries`` was deprecated officially in 0.17.0, though has only been an alias since 0.13.0. It has
been dropped in favor of ``pd.Series``.

This *may* cause pickles / HDF5 files that were created with the ``pd.TimeSeries`` to become unreadable. (:issue:``15098).

.. _whatsnew.api_breaking.index_map

Map on Index types now return other Index types
Expand Down Expand Up @@ -270,8 +280,7 @@ Removal of prior version deprecations/changes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- ``pd.to_datetime`` and ``pd.to_timedelta`` have dropped the ``coerce`` parameter in favor of ``errors`` (:issue:`13602`)


- ``Series.is_time_series`` is dropped in favor of ``Series.index.is_all_dates`` (:issue:``)


.. _whatsnew_0200.performance:
Expand Down
2 changes: 1 addition & 1 deletion pandas/api/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class TestPDApi(Base, tm.TestCase):
'TimedeltaIndex', 'Timestamp']

# these are already deprecated; awaiting removal
deprecated_classes = ['TimeSeries', 'WidePanel',
deprecated_classes = ['WidePanel',
'SparseTimeSeries', 'Panel4D',
'SparseList']

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pandas.core.index import (Index, CategoricalIndex, Int64Index,
RangeIndex, Float64Index, MultiIndex)

from pandas.core.series import Series, TimeSeries
from pandas.core.series import Series
from pandas.core.frame import DataFrame
from pandas.core.panel import Panel, WidePanel
from pandas.core.panel4d import Panel4D
Expand Down
16 changes: 0 additions & 16 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,6 @@ def _constructor_expanddim(self):
def _can_hold_na(self):
return self._data._can_hold_na

@property
def is_time_series(self):
warnings.warn("is_time_series is deprecated. Please use "
"Series.index.is_all_dates", FutureWarning, stacklevel=2)
# return self._subtyp in ['time_series', 'sparse_time_series']
return self.index.is_all_dates

_index = None

def _set_axis(self, axis, labels, fastpath=False):
Expand Down Expand Up @@ -2980,15 +2973,6 @@ def create_from_value(value, index, dtype):
return subarr


# backwards compatiblity
class TimeSeries(Series):
def __init__(self, *args, **kwargs):
# deprecation TimeSeries, #10890
warnings.warn("TimeSeries is deprecated. Please use Series",
FutureWarning, stacklevel=2)

super(TimeSeries, self).__init__(*args, **kwargs)

# ----------------------------------------------------------------------
# Add plotting methods to Series

Expand Down
4 changes: 0 additions & 4 deletions pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
from pandas.types.missing import array_equivalent

import numpy as np

import pandas as pd
from pandas import (Series, DataFrame, Panel, Panel4D, Index,
MultiIndex, Int64Index, isnull)
from pandas.core import config
Expand Down Expand Up @@ -164,7 +162,6 @@ class DuplicateWarning(Warning):

Series: u('series'),
SparseSeries: u('sparse_series'),
pd.TimeSeries: u('series'),
DataFrame: u('frame'),
SparseDataFrame: u('sparse_frame'),
Panel: u('wide'),
Expand All @@ -173,7 +170,6 @@ class DuplicateWarning(Warning):

# storer class map
_STORER_MAP = {
u('TimeSeries'): 'LegacySeriesFixed',
u('Series'): 'LegacySeriesFixed',
u('DataFrame'): 'LegacyFrameFixed',
u('DataMatrix'): 'LegacyFrameFixed',
Expand Down
Binary file removed pandas/io/tests/data/legacy_hdf/legacy.h5
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
9 changes: 0 additions & 9 deletions pandas/io/tests/test_pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -4458,15 +4458,6 @@ def test_pytables_native2_read(self):
d1 = store['detector']
self.assertIsInstance(d1, DataFrame)

def test_legacy_read(self):
with ensure_clean_store(
tm.get_data_path('legacy_hdf/legacy.h5'),
mode='r') as store:
store['a']
store['b']
store['c']
store['d']

def test_legacy_table_read(self):
# legacy table types
with ensure_clean_store(
Expand Down
Binary file removed pandas/tests/indexes/data/s1-0.12.0.pickle
Binary file not shown.
Binary file removed pandas/tests/indexes/data/s2-0.12.0.pickle
Binary file not shown.
11 changes: 0 additions & 11 deletions pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
from pandas.compat import (range, lrange, lzip, u,
zip, PY3, PY36)
import operator
import os

import numpy as np

from pandas import (period_range, date_range, Series,
Expand Down Expand Up @@ -381,15 +379,6 @@ def test_view_with_args(self):
# with arguments
ind.view('i8')

def test_legacy_pickle_identity(self):

# GH 8431
pth = tm.get_data_path()
s1 = pd.read_pickle(os.path.join(pth, 's1-0.12.0.pickle'))
s2 = pd.read_pickle(os.path.join(pth, 's2-0.12.0.pickle'))
self.assertFalse(s1.index.identical(s2.index))
self.assertFalse(s1.index.equals(s2.index))

def test_astype(self):
casted = self.intIndex.astype('i8')

Expand Down
3 changes: 0 additions & 3 deletions pandas/tests/series/test_alter_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@ def test_set_index_makes_timeseries(self):

s = Series(lrange(10))
s.index = idx

with tm.assert_produces_warning(FutureWarning):
self.assertTrue(s.is_time_series)
self.assertTrue(s.index.is_all_dates)

def test_reset_index(self):
Expand Down
15 changes: 0 additions & 15 deletions pandas/tests/series/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,11 @@ def test_scalar_conversion(self):
self.assertEqual(int(Series([1.])), 1)
self.assertEqual(long(Series([1.])), 1)

def test_TimeSeries_deprecation(self):

# deprecation TimeSeries, #10890
with tm.assert_produces_warning(FutureWarning):
pd.TimeSeries(1, index=date_range('20130101', periods=3))

def test_constructor(self):
# Recognize TimeSeries
with tm.assert_produces_warning(FutureWarning):
self.assertTrue(self.ts.is_time_series)
self.assertTrue(self.ts.index.is_all_dates)

# Pass in Series
derived = Series(self.ts)
with tm.assert_produces_warning(FutureWarning):
self.assertTrue(derived.is_time_series)
self.assertTrue(derived.index.is_all_dates)

self.assertTrue(tm.equalContents(derived.index, self.ts.index))
Expand All @@ -65,11 +54,7 @@ def test_constructor(self):
self.assertEqual(mixed.dtype, np.object_)
self.assertIs(mixed[1], np.NaN)

with tm.assert_produces_warning(FutureWarning):
self.assertFalse(self.empty.is_time_series)
self.assertFalse(self.empty.index.is_all_dates)
with tm.assert_produces_warning(FutureWarning):
self.assertFalse(Series({}).is_time_series)
self.assertFalse(Series({}).index.is_all_dates)
self.assertRaises(Exception, Series, np.random.randn(3, 3),
index=np.arange(3))
Expand Down
2 changes: 0 additions & 2 deletions pandas/tests/series/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,6 @@ def test_mpl_compat_hack(self):
def test_timeseries_coercion(self):
idx = tm.makeDateIndex(10000)
ser = Series(np.random.randn(len(idx)), idx.astype(object))
with tm.assert_produces_warning(FutureWarning):
self.assertTrue(ser.is_time_series)
self.assertTrue(ser.index.is_all_dates)
self.assertIsInstance(ser.index, DatetimeIndex)

Expand Down

0 comments on commit 6adcf80

Please sign in to comment.