Skip to content

DOC: to_datetime not type-stable on mixed timezones (possible bug) #40808

@mkovarik337

Description

@mkovarik337

Note: This behaviour might be a bug. I'm assuming its an undocumented feature.

Location of the documentation

pandas.to_datetime.html

Documentation problem

to_datetime outputs different types depending on if the timezones are mixed or not (assuming utc=True not passed in).

MIXED = ["2018-10-26 12:00 -0500", "2018-10-26 12:00 -0400"]
UNMIXED = ["2018-10-26 12:00 -0500", "2018-10-26 12:00 -0500"]

print(pandas.to_datetime(MIXED).dtype)   # ==> object
print(pandas.to_datetime(UNMIXED).dtype) # ==> datetime64[ns, pytz.FixedOffset(-300)]

Suggested fix for documentation

Specify aforementioned behaviour in documentation (in the returns section). Or, if not intentional feature, update the API to be type-stable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions