-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Doc: Update the DatetimeIndex.strftime docstring #20103
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,18 +61,39 @@ def strftime(self, date_format): | |
return np.asarray(self.format(date_format=date_format), | ||
dtype=compat.text_type) | ||
strftime.__doc__ = """ | ||
Convert to specified date_format. | ||
|
||
Return an array of formatted strings specified by date_format, which | ||
supports the same string format as the python standard library. Details | ||
of the string format can be found in `python string format doc <{0}>`__ | ||
|
||
Parameters | ||
---------- | ||
date_format : str | ||
date format string (e.g. "%Y-%m-%d") | ||
Date format string (e.g. "%Y-%m-%d"). | ||
|
||
Returns | ||
------- | ||
ndarray of formatted strings | ||
numpy.ndarray | ||
n-dimensional array of formatted strings | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would just say "NumPy array" instead of "n-dimensional", as it is always 1D There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jorisvandenbossche separate issue, this should actually return an |
||
|
||
See Also | ||
-------- | ||
DatetimeIndex.normalize : Return DatetimeIndex with times to midnight. | ||
DatetimeIndex.round : Round the DatetimeIndex to the specified freq. | ||
DatetimeIndex.floor : Floor the DatetimeIndex to the specified freq. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would also link to the similar conversion but other way around: to_datetime |
||
|
||
Examples | ||
-------- | ||
>>> data = ['2015-05-01 18:47:05.060000','2014-05-01 18:47:05.110000'] | ||
>>> df = pd.DataFrame(data, columns=['date']) | ||
>>> df.date = pd.to_datetime(df.date) | ||
>>> df.date[1] | ||
Timestamp('2014-05-01 18:47:05.110000') | ||
>>> df.date[1].strftime('%d-%m-%Y') | ||
'01-05-2014' | ||
>>> df.date[1].strftime('%B %d, %Y, %r') | ||
'May 01, 2014, 06:47:05 PM' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The docstring is from DatetimeIndex. Can you update the example to use that? (so eg create an example dataframe with DatetimeIndex with eg |
||
""".format("https://docs.python.org/3/library/datetime.html" | ||
"#strftime-and-strptime-behavior") | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe mention it is converted to a string?