Skip to content

Updated the return type section of to_datetime #42244

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 7 commits into from
Jul 11, 2021

Conversation

prabha-git
Copy link
Contributor

@prabha-git prabha-git commented Jun 26, 2021

Updated the return type section of to_datetime to include list-like mixed timezone inputs

@@ -765,6 +765,7 @@ def to_datetime(
- list-like: DatetimeIndex
- Series: Series of datetime64 dtype
- scalar: Timestamp
- list-like with mixed timezones: Index of object dtype
Copy link
Member

Choose a reason for hiding this comment

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

Actually on second thought might be better to combine with list-like: DatetimeIndex like

- Index:
    - DatetimeIndex if timezone naive or aware with the same timezone
    - Index of object dtype if timezone aware with mixed timezones

@mroeschke mroeschke added Docs Datetime Datetime data dtype labels Jun 26, 2021
@prabha-git
Copy link
Contributor Author

@mroeschke - updated as per you suggestion

- Series: Series of datetime64 dtype
- scalar: Timestamp


Copy link
Member

Choose a reason for hiding this comment

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

Nit: Could you remove this newline?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I can

Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

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

One small comment otherwise LGTM

@prabha-git
Copy link
Contributor Author

Removed the additional line , Thanks for patience and feedback @mroeschke

@@ -762,7 +762,9 @@ def to_datetime(
If parsing succeeded.
Return type depends on input:

- list-like: DatetimeIndex
- list-like:
- DatetimeIndex, if timezone naive or aware with the same timezone
Copy link
Contributor

@smarie smarie Jun 28, 2021

Choose a reason for hiding this comment

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

As discussed in #42229 (comment)

Suggested change
- DatetimeIndex, if timezone naive or aware with the same timezone
- DatetimeIndex, if timezone naive or aware with the same time offset

Co-authored-by: Sylvain Marié <sylvain.marie@schneider-electric.com>
@mroeschke
Copy link
Member

Thanks @prabha-git

smarie added a commit to smarie/pandas that referenced this pull request Jul 12, 2021
Following pandas-dev#42244 , improved documentation about datetime parsing.

See also pandas-dev#42229 (comment)
@smarie
Copy link
Contributor

smarie commented Jul 12, 2021

Hi @prabha-git and @mroeschke ! It seems that the resulting comment is half/half (half speaking about timezone, half speaking about time offset...). Therefore I created #42494 to complete this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: to_datetime() returns object instead of datetime type or raising exception
3 participants