Skip to content

ERR: FutureWarning difficult to identify source #26431

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

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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.25.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ Timezones
- Bug in :func:`to_datetime` where an uninformative ``RuntimeError`` was raised when passing a naive :class:`Timestamp` with datetime strings with mixed UTC offsets (:issue:`25978`)
- Bug in :func:`to_datetime` with ``unit='ns'`` would drop timezone information from the parsed argument (:issue:`26168`)
- Bug in :func:`DataFrame.join` where joining a timezone aware index with a timezone aware column would result in a column of ``NaN`` (:issue:`26335`)
- FutureWarning message raised by :func:`DatetimeIndex.to_series` updated to identify source of warning (:issue:`26329`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need a note for this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meta-question: with review requests like this, is it better to just merge? I also thought that the note was unnecessary, but the "harm" of this note is small. Maybe better to just merge, and reduce CI burden / risk of a merge conflict coming up?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don’t think the ci burden is relevant here
we are pretty fast now adays
and better to fix things even small typos on the first go
as once things are merged it is almost impossible to see that something is amiss


Numeric
^^^^^^^
Expand Down
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