Skip to content

Commit 948ba6a

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 8d57450 commit 948ba6a

20 files changed

+43
-64
lines changed

doc/source/whatsnew/v0.20.0.txt

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

206206

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

209249
Map on Index types now return other Index types
@@ -395,8 +435,7 @@ Removal of prior version deprecations/changes
395435
- The ``pandas.io.ga`` module with a ``google-analytics`` interface is removed (:issue:`11308`).
396436
Similar functionality can be found in the `Google2Pandas <https://github.com/panalysis/Google2Pandas>`__ package.
397437
- ``pd.to_datetime`` and ``pd.to_timedelta`` have dropped the ``coerce`` parameter in favor of ``errors`` (:issue:`13602`)
398-
399-
438+
- ``Series.is_time_series`` is dropped in favor of ``Series.index.is_all_dates`` (:issue:``)
400439

401440

402441
.. _whatsnew_0200.performance:

pandas/api/tests/test_api.py

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

6161
# these are already deprecated; awaiting removal
62-
deprecated_classes = ['TimeSeries', 'WidePanel',
62+
deprecated_classes = ['WidePanel',
6363
'SparseTimeSeries', 'Panel4D',
6464
'SparseList']
6565

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

-16
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,15 +2978,6 @@ def create_from_value(value, index, dtype):
29852978
return subarr
29862979

29872980

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

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)
3028
from pandas.core import config
@@ -164,7 +162,6 @@ class DuplicateWarning(Warning):
164162

165163
Series: u('series'),
166164
SparseSeries: u('sparse_series'),
167-
pd.TimeSeries: u('series'),
168165
DataFrame: u('frame'),
169166
SparseDataFrame: u('sparse_frame'),
170167
Panel: u('wide'),
@@ -173,7 +170,6 @@ class DuplicateWarning(Warning):
173170

174171
# storer class map
175172
_STORER_MAP = {
176-
u('TimeSeries'): 'LegacySeriesFixed',
177173
u('Series'): 'LegacySeriesFixed',
178174
u('DataFrame'): 'LegacyFrameFixed',
179175
u('DataMatrix'): 'LegacyFrameFixed',
-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/io/tests/test_pytables.py

-9
Original file line numberDiff line numberDiff line change
@@ -4463,15 +4463,6 @@ def test_pytables_native2_read(self):
44634463
d1 = store['detector']
44644464
self.assertIsInstance(d1, DataFrame)
44654465

4466-
def test_legacy_read(self):
4467-
with ensure_clean_store(
4468-
tm.get_data_path('legacy_hdf/legacy.h5'),
4469-
mode='r') as store:
4470-
store['a']
4471-
store['b']
4472-
store['c']
4473-
store['d']
4474-
44754466
def test_legacy_table_read(self):
44764467
# legacy table types
44774468
with ensure_clean_store(
-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,
@@ -382,15 +380,6 @@ def test_view_with_args(self):
382380
# with arguments
383381
ind.view('i8')
384382

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

pandas/tests/series/test_alter_axes.py

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

110110
s = Series(lrange(10))
111111
s.index = idx
112-
113-
with tm.assert_produces_warning(FutureWarning):
114-
self.assertTrue(s.is_time_series)
115112
self.assertTrue(s.index.is_all_dates)
116113

117114
def test_reset_index(self):

pandas/tests/series/test_constructors.py

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

42-
def test_TimeSeries_deprecation(self):
43-
44-
# deprecation TimeSeries, #10890
45-
with tm.assert_produces_warning(FutureWarning):
46-
pd.TimeSeries(1, index=date_range('20130101', periods=3))
47-
4842
def test_constructor(self):
49-
# Recognize TimeSeries
50-
with tm.assert_produces_warning(FutureWarning):
51-
self.assertTrue(self.ts.is_time_series)
5243
self.assertTrue(self.ts.index.is_all_dates)
5344

5445
# Pass in Series
5546
derived = Series(self.ts)
56-
with tm.assert_produces_warning(FutureWarning):
57-
self.assertTrue(derived.is_time_series)
5847
self.assertTrue(derived.index.is_all_dates)
5948

6049
self.assertTrue(tm.equalContents(derived.index, self.ts.index))
@@ -66,11 +55,7 @@ def test_constructor(self):
6655
self.assertEqual(mixed.dtype, np.object_)
6756
self.assertIs(mixed[1], np.NaN)
6857

69-
with tm.assert_produces_warning(FutureWarning):
70-
self.assertFalse(self.empty.is_time_series)
7158
self.assertFalse(self.empty.index.is_all_dates)
72-
with tm.assert_produces_warning(FutureWarning):
73-
self.assertFalse(Series({}).is_time_series)
7459
self.assertFalse(Series({}).index.is_all_dates)
7560
self.assertRaises(Exception, Series, np.random.randn(3, 3),
7661
index=np.arange(3))

pandas/tests/series/test_timeseries.py

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

0 commit comments

Comments
 (0)