Skip to content

Docstring changes to pandas.Series.dt.to_pydatetime #20198

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
Changes from 5 commits
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
20 changes: 20 additions & 0 deletions pandas/core/indexes/accessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,26 @@ class DatetimeProperties(Properties):
"""

def to_pydatetime(self):
"""
Return DatetimeIndex as an object ndarray.
Copy link
Member

Choose a reason for hiding this comment

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

I would mention it is an array of "native Python datetime objects" ?

Copy link
Member

@jorisvandenbossche jorisvandenbossche Mar 10, 2018

Choose a reason for hiding this comment

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

Can you change this to "Return Series" instead of "Return DatetimeIndex" (as it is the accessor on a Series) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, Kindly review


Returns
-------
ndarray 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.

-> Series of object dtype


See Also
--------
pandas.DatetimeIndex.to_pydatetime : Convert a Timestamp object to a native
Copy link
Member

Choose a reason for hiding this comment

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

This is now referencing itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Ah, sorry! Missed that this one was in accessors.py.

Python datetime object.

Examples
--------
>>> df = pd.Series(pd.date_range('20180310', periods=2))
Copy link
Member

Choose a reason for hiding this comment

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

Can you call this s instead of df (since it is a Series)

>>> type(df)
<class 'pandas.core.series.Series'>
Copy link
Member

Choose a reason for hiding this comment

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

This is not needed I think

>>> type(df.dt.to_pydatetime())
Copy link
Member

Choose a reason for hiding this comment

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

I would actually show the output here, instead of inspecting the type (that will also show it is an array, but also show it holds datetime.datetime objects)

<class 'numpy.ndarray'>
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

I gave up on a tz example since the repr for datetime w/ tz is so long. Wasn't able to make it look nice.

return self._get_values().to_pydatetime()

@property
Expand Down