Skip to content

DEPR: remove pd.TimeSeries & Series.is_time_series #15098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion doc/source/whatsnew/v0.20.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,46 @@ Using ``.iloc``. Here we will get the location of the 'A' column, then use *posi
df.iloc[[0, 2], df.columns.get_loc('A')]


.. _whatsnew.api_breaking.io_compat

Possible incompat for HDF5 formats for pandas < 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``. (:issue:``15098).

This *may* cause HDF5 files that were created in prior versions to become unreadable if ``pd.TimeSeries``
was used. This is most likely to be for pandas < 0.13.0. If you find yourself in this situation.
You can use a recent prior version of pandas to read in your HDF5 files,
then write them out again after applying the procedure below.

.. code-block:: ipython

In [2]: s = pd.TimeSeries([1,2,3], index=pd.date_range('20130101', periods=3))

In [3]: s
Out[3]:
2013-01-01 1
2013-01-02 2
2013-01-03 3
Freq: D, dtype: int64

In [4]: type(s)
Out[4]: pandas.core.series.TimeSeries

In [5]: s = pd.Series(s)

In [6]: s
Out[6]:
2013-01-01 1
2013-01-02 2
2013-01-03 3
Freq: D, dtype: int64

In [7]: type(s)
Out[7]: pandas.core.series.Series


.. _whatsnew_0200.api_breaking.index_map:

Map on Index types now return other Index types
Expand Down Expand Up @@ -506,7 +546,7 @@ Removal of prior version deprecations/changes
Similar functionality can be found in the `Google2Pandas <https://github.com/panalysis/Google2Pandas>`__ package.
- ``pd.to_datetime`` and ``pd.to_timedelta`` have dropped the ``coerce`` parameter in favor of ``errors`` (:issue:`13602`)
- ``pandas.stats.fama_macbeth``, ``pandas.stats.ols``, ``pandas.stats.plm`` and ``pandas.stats.var``, as well as the top-level ``pandas.fama_macbeth`` and ``pandas.ols`` routines are removed. Similar functionaility can be found in the `statsmodels <shttp://www.statsmodels.org/dev/>`__ package. (:issue:`11898`)

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


.. _whatsnew_0200.performance:
Expand Down
5 changes: 4 additions & 1 deletion pandas/compat/pickle_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ def load_reduce(self):

# 15477
('pandas.core.base', 'FrozenNDArray'): ('pandas.indexes.frozen', 'FrozenNDArray'),
('pandas.core.base', 'FrozenList'): ('pandas.indexes.frozen', 'FrozenList')
('pandas.core.base', 'FrozenList'): ('pandas.indexes.frozen', 'FrozenList'),

# 10890
('pandas.core.series', 'TimeSeries'): ('pandas.core.series', 'Series')
}


Expand Down
2 changes: 1 addition & 1 deletion pandas/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
UInt64Index, 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
17 changes: 0 additions & 17 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,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 @@ -2985,16 +2978,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, concat,
SparseSeries, SparseDataFrame, PeriodIndex,
Expand Down Expand Up @@ -166,7 +164,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 @@ -175,7 +172,6 @@ class DuplicateWarning(Warning):

# storer class map
_STORER_MAP = {
u('TimeSeries'): 'LegacySeriesFixed',
u('Series'): 'LegacySeriesFixed',
u('DataFrame'): 'LegacyFrameFixed',
u('DataMatrix'): 'LegacyFrameFixed',
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,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
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,
text_type, 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
Binary file removed pandas/tests/io/data/legacy_hdf/legacy.h5
Binary file not shown.
9 changes: 0 additions & 9 deletions pandas/tests/io/test_pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -4454,15 +4454,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
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 @@ -107,9 +107,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 @@ -37,22 +37,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 @@ -64,11 +53,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 @@ -383,8 +383,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