Skip to content
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

DEPR: Series.is_timeseries #11135

Merged
merged 1 commit into from
Sep 17, 2015
Merged
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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.17.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,7 @@ Deprecations
``DataFrame.add(other, fill_value=0)`` and ``DataFrame.mul(other, fill_value=1.)``
(:issue:`10735`).
- ``TimeSeries`` deprecated in favor of ``Series`` (note that this has been alias since 0.13.0), (:issue:`10890`)
- ``Series.is_time_series`` deprecated in favor of ``Series.index.is_all_dates`` (:issue:`11135`)
- 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`)
- ``WidePanel`` deprecated in favor of ``Panel``, ``LongPanel`` in favor of ``DataFrame`` (note these have been aliases since < 0.11.0), (:issue:`10892`)

Expand Down
6 changes: 5 additions & 1 deletion pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,11 @@ def _can_hold_na(self):

@property
def is_time_series(self):
return self._subtyp in ['time_series', 'sparse_time_series']
msg = "is_time_series is deprecated. Please use Series.index.is_all_dates"
warnings.warn(msg, FutureWarning, stacklevel=2)
# return self._subtyp in ['time_series', 'sparse_time_series']
return self.index.is_all_dates


_index = None

Expand Down
25 changes: 18 additions & 7 deletions pandas/tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,11 +703,15 @@ def test_TimeSeries_deprecation(self):

def test_constructor(self):
# Recognize TimeSeries
self.assertTrue(self.ts.is_time_series)
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)
self.assertTrue(derived.is_time_series)
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))
# Ensure new index is not created
Expand All @@ -718,9 +722,12 @@ def test_constructor(self):
self.assertEqual(mixed.dtype, np.object_)
self.assertIs(mixed[1], np.NaN)

self.assertFalse(self.empty.is_time_series)
self.assertFalse(Series({}).is_time_series)

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 Expand Up @@ -7693,12 +7700,16 @@ def test_set_index_makes_timeseries(self):
s = Series(lrange(10))
s.index = idx

self.assertTrue(s.is_time_series == True)
with tm.assert_produces_warning(FutureWarning):
self.assertTrue(s.is_time_series == True)
self.assertTrue(s.index.is_all_dates == True)

def test_timeseries_coercion(self):
idx = tm.makeDateIndex(10000)
ser = Series(np.random.randn(len(idx)), idx.astype(object))
self.assertTrue(ser.is_time_series)
with tm.assert_produces_warning(FutureWarning):
self.assertTrue(ser.is_time_series)
self.assertTrue(ser.index.is_all_dates)
self.assertIsInstance(ser.index, DatetimeIndex)

def test_replace(self):
Expand Down