Skip to content

FutureWarning difficult to identify source #26329

Closed
@david-waterworth

Description

@david-waterworth

This is a suggestion, not a bug. The following resulted in a FutureWarning

df = df.assign(block=(df.index.to_series().diff() != pd.Timedelta(15,'m')).cumsum())

FutureWarning: The default of the 'keep_tz' keyword will change to True in a future release. You can set 'keep_tz=True' to obtain the future behaviour and silence this warning.

It wasn't in any way obvious why since the warning doesn't mention the method name and there's no stack trace (and futures warnings are only printed once). I had to search the source (which was also difficult as the message was split to maintain a character limit per line).

It would be nice if future warnings were more explicit, i.e. name the class and method as well as the argument.

(In this case it's the to_series() method, which ideally wouldn't be required but DateTimeIndex doesn't yet implement diff())

Metadata

Metadata

Assignees

No one assigned

    Labels

    Error ReportingIncorrect or improved errors from pandas

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions