Skip to content
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

DOC: Improve to_datetime() documentation #41049

Merged
merged 8 commits into from
Apr 21, 2021

Conversation

chinmayrane
Copy link
Contributor

Returns Object Type Index when Mixed Timezones are used in list-like input to pandas.to_datetime()

Returns Object Type Index when Mixed Timezones are used in list-like input to pandas.to_datetime()
@pep8speaks
Copy link

pep8speaks commented Apr 20, 2021

Hello @chinmayrane! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2021-04-21 13:33:33 UTC

@@ -786,6 +786,10 @@ def to_datetime(
return will have datetime.datetime type (or corresponding
array/Series).

In case input is list-like and the elements of input are of mixed
Copy link
Member

@mroeschke mroeschke Apr 20, 2021

Choose a reason for hiding this comment

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

Mind adding this paragraph and an example in the Examples section?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I've added it with the Examples section.

Copy link
Member

Choose a reason for hiding this comment

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

This paragraph can now be removed since you have it in the examples now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, will remove it from the Returns

@mroeschke mroeschke added the Docs label Apr 20, 2021
Chinmay Rane added 2 commits April 20, 2021 00:35
Add Examples for the mixed Timezones for pandas.to_datetime()
Add Examples for the mixed Timezones for pandas.to_datetime()
@chinmayrane
Copy link
Contributor Author

chinmayrane commented Apr 20, 2021

Test Failure seems unrelated. This is my first PR, so wanted to make sure, if I understand it correctly.

Seeing Error on - TestSeriesReductions.test_empty_multi

AssertionError: Caused unexpected warning(s): [('ResourceWarning', ResourceWarning('unclosed transport <asyncio.sslproto._SSLProtocolTransport object at 0x000001B4D3B9EE20>'), 'C:\\Miniconda\\envs\\pandas-dev\\lib\\asyncio\\sslproto.py', 321)]

Also got a pop up on the Azure Pipeline that this test has failed 124 times in the past 14 days.

Test Failure

@chinmayrane chinmayrane requested a review from mroeschke April 20, 2021 05:54
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.

LGTM (that is a known flakey test in our CI, so unrelated to this PR)

@mroeschke mroeschke added this to the 1.3 milestone Apr 20, 2021
@chinmayrane
Copy link
Contributor Author

@mroeschke Thanks!

@@ -853,6 +857,13 @@ def to_datetime(
... origin=pd.Timestamp('1960-01-01'))
DatetimeIndex(['1960-01-02', '1960-01-03', '1960-01-04'], \
dtype='datetime64[ns]', freq=None)

In case input is list-like and the elements of input are of mixed
timezones, return will have object type Index if utc parameter is not
Copy link
Contributor

Choose a reason for hiding this comment

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

say if utc=False

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

@@ -786,6 +786,10 @@ def to_datetime(
return will have datetime.datetime type (or corresponding
array/Series).

In case input is list-like and the elements of input are of mixed
timezones, return will have object type Index if utc parameter is not
Copy link
Contributor

Choose a reason for hiding this comment

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

say if utc=False

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

timezones, return will have object type Index if utc parameter is not
passed in as True.

>>> pd.to_datetime(['2018-10-26 12:00 -0530', '2018-10-26 12:00 -0500'])
Copy link
Contributor

Choose a reason for hiding this comment

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

ok to show the same example with utc=True as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added an example with utc=True

@jreback jreback added the Datetime Datetime data dtype label Apr 20, 2021
Chinmay Rane added 2 commits April 20, 2021 15:05
Add Examples for utc=True, For mixed Timezones on function pandas.to_datetime(), Edit Description to specify utc=False instead of verbose text about parameter
Remove Text fromReturns Section as it's specified in the Examples
>>> pd.to_datetime(['2018-10-26 12:00 -0530', '2018-10-26 12:00 -0500'],
... utc=True)
DatetimeIndex(['2018-10-26 17:30:00+00:00', '2018-10-26 17:00:00+00:00'], \
dtype='datetime64[ns, UTC]', freq=None)
Copy link
Contributor

Choose a reason for hiding this comment

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

does this render properly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry about that. Added a fix for the rendering.
It now renders like below -

image

Fix a rendering Issue so that the DateTimeIndex Output is split on 2 lines
@@ -853,6 +853,17 @@ def to_datetime(
... origin=pd.Timestamp('1960-01-01'))
DatetimeIndex(['1960-01-02', '1960-01-03', '1960-01-04'], \
dtype='datetime64[ns]', freq=None)

Copy link
Contributor

Choose a reason for hiding this comment

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

can you fix the one right above as well, thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Have fixed the example above.

Fix a rendering Issue so that the DateTimeIndex Output is split on 2 lines
@jreback jreback merged commit 0bd8138 into pandas-dev:master Apr 21, 2021
@jreback
Copy link
Contributor

jreback commented Apr 21, 2021

thanks @chinmayrane

yeshsurya pushed a commit to yeshsurya/pandas that referenced this pull request May 6, 2021
JulianWgs pushed a commit to JulianWgs/pandas that referenced this pull request Jul 3, 2021
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.

DOC: to_datetime not type-stable on mixed timezones (possible bug)
4 participants