Skip to content

Commit 7ee26a8

Browse files
simonjayhawkinsjreback
authored andcommitted
ERR: FutureWarning difficult to identify source (#26431)
1 parent 07cbadc commit 7ee26a8

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pandas/core/indexes/datetimes.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,8 @@ def to_series(self, keep_tz=None, index=None, name=None):
689689
name = self.name
690690

691691
if keep_tz is None and self.tz is not None:
692-
warnings.warn("The default of the 'keep_tz' keyword will change "
692+
warnings.warn("The default of the 'keep_tz' keyword in "
693+
"DatetimeIndex.to_series will change "
693694
"to True in a future release. You can set "
694695
"'keep_tz=True' to obtain the future behaviour and "
695696
"silence this warning.", FutureWarning, stacklevel=2)

pandas/tests/frame/test_alter_axes.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,13 @@ def test_convert_dti_to_series(self):
460460
name='B')
461461
tm.assert_series_equal(result, comp)
462462

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

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

0 commit comments

Comments
 (0)