Skip to content
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
3 changes: 2 additions & 1 deletion pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,8 @@ def to_series(self, keep_tz=None, index=None, name=None):
name = self.name

if keep_tz is None and self.tz is not None:
warnings.warn("The default of the 'keep_tz' keyword will change "
warnings.warn("The default of the 'keep_tz' keyword in "
"DatetimeIndex.to_series will change "
"to True in a future release. You can set "
"'keep_tz=True' to obtain the future behaviour and "
"silence this warning.", FutureWarning, stacklevel=2)
Expand Down
6 changes: 5 additions & 1 deletion pandas/tests/frame/test_alter_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,13 @@ def test_convert_dti_to_series(self):
name='B')
tm.assert_series_equal(result, comp)

with tm.assert_produces_warning(FutureWarning):
with tm.assert_produces_warning(FutureWarning) as m:
result = idx.to_series(index=[0, 1])
tm.assert_series_equal(result, expected.dt.tz_convert(None))
msg = ("The default of the 'keep_tz' keyword in "
"DatetimeIndex.to_series will change to True in a future "
"release.")
assert msg in str(m[0].message)

with tm.assert_produces_warning(FutureWarning):
result = idx.to_series(keep_tz=False, index=[0, 1])
Expand Down