Skip to content

Commit 4116d9e

Browse files
jrebackAnkurDedania
authored andcommitted
DEPR: remove pd.TimeSeries & Series.is_time_series
xref pandas-dev#10890 Author: Jeff Reback <[email protected]> Closes pandas-dev#15098 from jreback/time_series and squashes the following commits: d9101bc [Jeff Reback] fix back-compat for < 0.13 ed57bd5 [Jeff Reback] DEPR: remove legacy pd.TimeSeries class in favor of pd.Series
1 parent afae797 commit 4116d9e

File tree

14 files changed

+47
-65
lines changed

14 files changed

+47
-65
lines changed

doc/source/whatsnew/v0.20.0.txt

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

248248

249+
.. _whatsnew.api_breaking.io_compat
250+
251+
Possible incompat for HDF5 formats for pandas < 0.13.0
252+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
253+
254+
``pd.TimeSeries`` was deprecated officially in 0.17.0, though has only been an alias since 0.13.0. It has
255+
been dropped in favor of ``pd.Series``. (:issue:``15098).
256+
257+
This *may* cause HDF5 files that were created in prior versions to become unreadable if ``pd.TimeSeries``
258+
was used. This is most likely to be for pandas < 0.13.0. If you find yourself in this situation.
259+
You can use a recent prior version of pandas to read in your HDF5 files,
260+
then write them out again after applying the procedure below.
261+
262+
.. code-block:: ipython
263+
264+
In [2]: s = pd.TimeSeries([1,2,3], index=pd.date_range('20130101', periods=3))
265+
266+
In [3]: s
267+
Out[3]:
268+
2013-01-01 1
269+
2013-01-02 2
270+
2013-01-03 3
271+
Freq: D, dtype: int64
272+
273+
In [4]: type(s)
274+
Out[4]: pandas.core.series.TimeSeries
275+
276+
In [5]: s = pd.Series(s)
277+
278+
In [6]: s
279+
Out[6]:
280+
2013-01-01 1
281+
2013-01-02 2
282+
2013-01-03 3
283+
Freq: D, dtype: int64
284+
285+
In [7]: type(s)
286+
Out[7]: pandas.core.series.Series
287+
288+
249289
.. _whatsnew_0200.api_breaking.index_map:
250290

251291
Map on Index types now return other Index types
@@ -507,7 +547,7 @@ Removal of prior version deprecations/changes
507547
Similar functionality can be found in the `Google2Pandas <https://github.com/panalysis/Google2Pandas>`__ package.
508548
- ``pd.to_datetime`` and ``pd.to_timedelta`` have dropped the ``coerce`` parameter in favor of ``errors`` (:issue:`13602`)
509549
- ``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`)
510-
550+
- ``Series.is_time_series`` is dropped in favor of ``Series.index.is_all_dates`` (:issue:``)
511551

512552

513553
.. _whatsnew_0200.performance:

pandas/compat/pickle_compat.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ def load_reduce(self):
5858

5959
# 15477
6060
('pandas.core.base', 'FrozenNDArray'): ('pandas.indexes.frozen', 'FrozenNDArray'),
61-
('pandas.core.base', 'FrozenList'): ('pandas.indexes.frozen', 'FrozenList')
61+
('pandas.core.base', 'FrozenList'): ('pandas.indexes.frozen', 'FrozenList'),
62+
63+
# 10890
64+
('pandas.core.series', 'TimeSeries'): ('pandas.core.series', 'Series')
6265
}
6366

6467

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,
@@ -166,7 +164,6 @@ class DuplicateWarning(Warning):
166164

167165
Series: u('series'),
168166
SparseSeries: u('sparse_series'),
169-
pd.TimeSeries: u('series'),
170167
DataFrame: u('frame'),
171168
SparseDataFrame: u('sparse_frame'),
172169
Panel: u('wide'),
@@ -175,7 +172,6 @@ class DuplicateWarning(Warning):
175172

176173
# storer class map
177174
_STORER_MAP = {
178-
u('TimeSeries'): 'LegacySeriesFixed',
179175
u('Series'): 'LegacySeriesFixed',
180176
u('DataFrame'): 'LegacyFrameFixed',
181177
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.

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)