Skip to content

Commit 9b13641

Browse files
committed
Merge pull request pandas-dev#11135 from sinhrks/timeseries_depr
DEPR: Series.is_timeseries
2 parents 6785475 + e0cc042 commit 9b13641

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

doc/source/whatsnew/v0.17.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,7 @@ Deprecations
964964
``DataFrame.add(other, fill_value=0)`` and ``DataFrame.mul(other, fill_value=1.)``
965965
(:issue:`10735`).
966966
- ``TimeSeries`` deprecated in favor of ``Series`` (note that this has been alias since 0.13.0), (:issue:`10890`)
967+
- ``Series.is_time_series`` deprecated in favor of ``Series.index.is_all_dates`` (:issue:`11135`)
967968
- Legacy offsets (like ``'A@JAN'``) listed in :ref:`here <timeseries.legacyaliases>` are deprecated (note that this has been alias since 0.8.0), (:issue:`10878`)
968969
- ``WidePanel`` deprecated in favor of ``Panel``, ``LongPanel`` in favor of ``DataFrame`` (note these have been aliases since < 0.11.0), (:issue:`10892`)
969970

pandas/core/series.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,11 @@ def _can_hold_na(self):
251251

252252
@property
253253
def is_time_series(self):
254-
return self._subtyp in ['time_series', 'sparse_time_series']
254+
msg = "is_time_series is deprecated. Please use Series.index.is_all_dates"
255+
warnings.warn(msg, FutureWarning, stacklevel=2)
256+
# return self._subtyp in ['time_series', 'sparse_time_series']
257+
return self.index.is_all_dates
258+
255259

256260
_index = None
257261

pandas/tests/test_series.py

+18-7
Original file line numberDiff line numberDiff line change
@@ -703,11 +703,15 @@ def test_TimeSeries_deprecation(self):
703703

704704
def test_constructor(self):
705705
# Recognize TimeSeries
706-
self.assertTrue(self.ts.is_time_series)
706+
with tm.assert_produces_warning(FutureWarning):
707+
self.assertTrue(self.ts.is_time_series)
708+
self.assertTrue(self.ts.index.is_all_dates)
707709

708710
# Pass in Series
709711
derived = Series(self.ts)
710-
self.assertTrue(derived.is_time_series)
712+
with tm.assert_produces_warning(FutureWarning):
713+
self.assertTrue(derived.is_time_series)
714+
self.assertTrue(derived.index.is_all_dates)
711715

712716
self.assertTrue(tm.equalContents(derived.index, self.ts.index))
713717
# Ensure new index is not created
@@ -718,9 +722,12 @@ def test_constructor(self):
718722
self.assertEqual(mixed.dtype, np.object_)
719723
self.assertIs(mixed[1], np.NaN)
720724

721-
self.assertFalse(self.empty.is_time_series)
722-
self.assertFalse(Series({}).is_time_series)
723-
725+
with tm.assert_produces_warning(FutureWarning):
726+
self.assertFalse(self.empty.is_time_series)
727+
self.assertFalse(self.empty.index.is_all_dates)
728+
with tm.assert_produces_warning(FutureWarning):
729+
self.assertFalse(Series({}).is_time_series)
730+
self.assertFalse(Series({}).index.is_all_dates)
724731
self.assertRaises(Exception, Series, np.random.randn(3, 3),
725732
index=np.arange(3))
726733

@@ -7693,12 +7700,16 @@ def test_set_index_makes_timeseries(self):
76937700
s = Series(lrange(10))
76947701
s.index = idx
76957702

7696-
self.assertTrue(s.is_time_series == True)
7703+
with tm.assert_produces_warning(FutureWarning):
7704+
self.assertTrue(s.is_time_series == True)
7705+
self.assertTrue(s.index.is_all_dates == True)
76977706

76987707
def test_timeseries_coercion(self):
76997708
idx = tm.makeDateIndex(10000)
77007709
ser = Series(np.random.randn(len(idx)), idx.astype(object))
7701-
self.assertTrue(ser.is_time_series)
7710+
with tm.assert_produces_warning(FutureWarning):
7711+
self.assertTrue(ser.is_time_series)
7712+
self.assertTrue(ser.index.is_all_dates)
77027713
self.assertIsInstance(ser.index, DatetimeIndex)
77037714

77047715
def test_replace(self):

0 commit comments

Comments
 (0)