Skip to content

Commit 780a92c

Browse files
committed
DEPR: remove legacy pd.TimeSeries class in favor of pd.Series
xref pandas-dev#10890 DEPR: remove Series.is_time_series in favor of Series.index.is_all_dates
1 parent a0f7fc0 commit 780a92c

20 files changed

+43
-64
lines changed

doc/source/whatsnew/v0.20.0.txt

+41-1
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,46 @@ Using ``.iloc``. Here we will get the location of the 'A' column, then use *posi
208208
df.iloc[[0, 2], df.columns.get_loc('A')]
209209

210210

211+
.. _whatsnew.api_breaking.io_compat
212+
213+
Possible incompat for pickle and HDF5 formats for pandas < 0.13.0
214+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
215+
216+
``pd.TimeSeries`` was deprecated officially in 0.17.0, though has only been an alias since 0.13.0. It has
217+
been dropped in favor of ``pd.Series``. (:issue:``15098).
218+
219+
This *may* cause pickles / HDF5 files that were created in prior versions to become unreadable if ``pd.TimeSeries``
220+
was used. This is most likely to be for pandas < 0.13.0. If you find yourself in this situation.
221+
You can use a recent prior version of pandas to read in your pickle / HDF5 files,
222+
then write them out again after applying the procedure below.
223+
224+
.. code-block:: ipython
225+
226+
In [2]: s = pd.TimeSeries([1,2,3], index=pd.date_range('20130101', periods=3))
227+
228+
In [3]: s
229+
Out[3]:
230+
2013-01-01 1
231+
2013-01-02 2
232+
2013-01-03 3
233+
Freq: D, dtype: int64
234+
235+
In [4]: type(s)
236+
Out[4]: pandas.core.series.TimeSeries
237+
238+
In [5]: s = pd.Series(s)
239+
240+
In [6]: s
241+
Out[6]:
242+
2013-01-01 1
243+
2013-01-02 2
244+
2013-01-03 3
245+
Freq: D, dtype: int64
246+
247+
In [7]: type(s)
248+
Out[7]: pandas.core.series.Series
249+
250+
211251
.. _whatsnew_0200.api_breaking.index_map:
212252

213253
Map on Index types now return other Index types
@@ -456,7 +496,7 @@ Removal of prior version deprecations/changes
456496
Similar functionality can be found in the `Google2Pandas <https://github.com/panalysis/Google2Pandas>`__ package.
457497
- ``pd.to_datetime`` and ``pd.to_timedelta`` have dropped the ``coerce`` parameter in favor of ``errors`` (:issue:`13602`)
458498
- ``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`)
459-
499+
- ``Series.is_time_series`` is dropped in favor of ``Series.index.is_all_dates`` (:issue:``)
460500

461501

462502
.. _whatsnew_0200.performance:

pandas/core/api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
UInt64Index, RangeIndex, Float64Index,
1414
MultiIndex)
1515

16-
from pandas.core.series import Series, TimeSeries
16+
from pandas.core.series import Series
1717
from pandas.core.frame import DataFrame
1818
from pandas.core.panel import Panel, WidePanel
1919
from pandas.core.panel4d import Panel4D

pandas/core/series.py

-17
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,6 @@ def _constructor_expanddim(self):
277277
def _can_hold_na(self):
278278
return self._data._can_hold_na
279279

280-
@property
281-
def is_time_series(self):
282-
warnings.warn("is_time_series is deprecated. Please use "
283-
"Series.index.is_all_dates", FutureWarning, stacklevel=2)
284-
# return self._subtyp in ['time_series', 'sparse_time_series']
285-
return self.index.is_all_dates
286-
287280
_index = None
288281

289282
def _set_axis(self, axis, labels, fastpath=False):
@@ -2985,16 +2978,6 @@ def create_from_value(value, index, dtype):
29852978
return subarr
29862979

29872980

2988-
# backwards compatiblity
2989-
class TimeSeries(Series):
2990-
2991-
def __init__(self, *args, **kwargs):
2992-
# deprecation TimeSeries, #10890
2993-
warnings.warn("TimeSeries is deprecated. Please use Series",
2994-
FutureWarning, stacklevel=2)
2995-
2996-
super(TimeSeries, self).__init__(*args, **kwargs)
2997-
29982981
# ----------------------------------------------------------------------
29992982
# Add plotting methods to Series
30002983

pandas/io/pytables.py

-4
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
from pandas.types.missing import array_equivalent
2424

2525
import numpy as np
26-
27-
import pandas as pd
2826
from pandas import (Series, DataFrame, Panel, Panel4D, Index,
2927
MultiIndex, Int64Index, isnull, concat,
3028
SparseSeries, SparseDataFrame, PeriodIndex,
@@ -162,7 +160,6 @@ class DuplicateWarning(Warning):
162160

163161
Series: u('series'),
164162
SparseSeries: u('sparse_series'),
165-
pd.TimeSeries: u('series'),
166163
DataFrame: u('frame'),
167164
SparseDataFrame: u('sparse_frame'),
168165
Panel: u('wide'),
@@ -171,7 +168,6 @@ class DuplicateWarning(Warning):
171168

172169
# storer class map
173170
_STORER_MAP = {
174-
u('TimeSeries'): 'LegacySeriesFixed',
175171
u('Series'): 'LegacySeriesFixed',
176172
u('DataFrame'): 'LegacyFrameFixed',
177173
u('DataMatrix'): 'LegacyFrameFixed',

pandas/tests/api/test_api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class TestPDApi(Base, tm.TestCase):
5757
'TimedeltaIndex', 'Timestamp']
5858

5959
# these are already deprecated; awaiting removal
60-
deprecated_classes = ['TimeSeries', 'WidePanel',
60+
deprecated_classes = ['WidePanel',
6161
'SparseTimeSeries', 'Panel4D',
6262
'SparseList']
6363

-862 Bytes
Binary file not shown.
-814 Bytes
Binary file not shown.

pandas/tests/indexes/test_base.py

-11
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
from pandas.compat import (range, lrange, lzip, u,
1010
text_type, zip, PY3, PY36)
1111
import operator
12-
import os
13-
1412
import numpy as np
1513

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

384-
def test_legacy_pickle_identity(self):
385-
386-
# GH 8431
387-
pth = tm.get_data_path()
388-
s1 = pd.read_pickle(os.path.join(pth, 's1-0.12.0.pickle'))
389-
s2 = pd.read_pickle(os.path.join(pth, 's2-0.12.0.pickle'))
390-
self.assertFalse(s1.index.identical(s2.index))
391-
self.assertFalse(s1.index.equals(s2.index))
392-
393382
def test_astype(self):
394383
casted = self.intIndex.astype('i8')
395384

-14.6 KB
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.

pandas/tests/io/test_pytables.py

-9
Original file line numberDiff line numberDiff line change
@@ -4454,15 +4454,6 @@ def test_pytables_native2_read(self):
44544454
d1 = store['detector']
44554455
self.assertIsInstance(d1, DataFrame)
44564456

4457-
def test_legacy_read(self):
4458-
with ensure_clean_store(
4459-
tm.get_data_path('legacy_hdf/legacy.h5'),
4460-
mode='r') as store:
4461-
store['a']
4462-
store['b']
4463-
store['c']
4464-
store['d']
4465-
44664457
def test_legacy_table_read(self):
44674458
# legacy table types
44684459
with ensure_clean_store(

pandas/tests/series/test_alter_axes.py

-3
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,6 @@ def test_set_index_makes_timeseries(self):
107107

108108
s = Series(lrange(10))
109109
s.index = idx
110-
111-
with tm.assert_produces_warning(FutureWarning):
112-
self.assertTrue(s.is_time_series)
113110
self.assertTrue(s.index.is_all_dates)
114111

115112
def test_reset_index(self):

pandas/tests/series/test_constructors.py

-15
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,11 @@ def test_scalar_conversion(self):
3737
self.assertEqual(int(Series([1.])), 1)
3838
self.assertEqual(long(Series([1.])), 1)
3939

40-
def test_TimeSeries_deprecation(self):
41-
42-
# deprecation TimeSeries, #10890
43-
with tm.assert_produces_warning(FutureWarning):
44-
pd.TimeSeries(1, index=date_range('20130101', periods=3))
45-
4640
def test_constructor(self):
47-
# Recognize TimeSeries
48-
with tm.assert_produces_warning(FutureWarning):
49-
self.assertTrue(self.ts.is_time_series)
5041
self.assertTrue(self.ts.index.is_all_dates)
5142

5243
# Pass in Series
5344
derived = Series(self.ts)
54-
with tm.assert_produces_warning(FutureWarning):
55-
self.assertTrue(derived.is_time_series)
5645
self.assertTrue(derived.index.is_all_dates)
5746

5847
self.assertTrue(tm.equalContents(derived.index, self.ts.index))
@@ -64,11 +53,7 @@ def test_constructor(self):
6453
self.assertEqual(mixed.dtype, np.object_)
6554
self.assertIs(mixed[1], np.NaN)
6655

67-
with tm.assert_produces_warning(FutureWarning):
68-
self.assertFalse(self.empty.is_time_series)
6956
self.assertFalse(self.empty.index.is_all_dates)
70-
with tm.assert_produces_warning(FutureWarning):
71-
self.assertFalse(Series({}).is_time_series)
7257
self.assertFalse(Series({}).index.is_all_dates)
7358
self.assertRaises(Exception, Series, np.random.randn(3, 3),
7459
index=np.arange(3))

pandas/tests/series/test_timeseries.py

-2
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,6 @@ def test_mpl_compat_hack(self):
383383
def test_timeseries_coercion(self):
384384
idx = tm.makeDateIndex(10000)
385385
ser = Series(np.random.randn(len(idx)), idx.astype(object))
386-
with tm.assert_produces_warning(FutureWarning):
387-
self.assertTrue(ser.is_time_series)
388386
self.assertTrue(ser.index.is_all_dates)
389387
self.assertIsInstance(ser.index, DatetimeIndex)
390388

0 commit comments

Comments
 (0)