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

def to_pydatetime(self):
"""
Return DatetimeIndex as object ndarray of datetime.datetime objects.
Copy link
Contributor

Choose a reason for hiding this comment

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

Return DatetimeIndex as an object ndarray

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Fixed it.


This function converts the Pandas Series DatetimeIndex to
Copy link
Contributor

Choose a reason for hiding this comment

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

would remove this extended summary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

a ndarray object. These two types are different and hence
2 differnt functions.

Returns
-------
datetimes : ndarray
Copy link
Contributor

Choose a reason for hiding this comment

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

ndarray of object dtype

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.


See Also
--------
pd.DatetimeIndex.to_pydatetime : Convert a Timestamp object to a native
Copy link
Contributor

Choose a reason for hiding this comment

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

pandas.DatetimeIndex.to_pydatetime

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Python datetime object.
pd.date.dt.values.to_datetime : For an Index containing strings or
Copy link
Contributor

Choose a reason for hiding this comment

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

remove this 2nd part which is not valid

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

datetime.datetime objects, attempt conversion to DatetimeIndex.

Examples
--------
>>> df = pd.DataFrame({'date': [pd.to_datetime('2018-03-10'), pd.to_datetime('2017-02-01')]})
Copy link
Contributor

Choose a reason for hiding this comment

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

make a series like: In [1]: Series(pd.date_range('20180310', periods=2))
show its return, then show the return of using .dt.to_pytdatetime()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

>>> type(df)
<class 'pandas.core.frame.DataFrame'>
>>> type(df.date.dt.to_pydatetime())
<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