-
-
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
Conversation
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.
Thanks for the PR! Added some comments
pandas/core/indexes/datetimelike.py
Outdated
@@ -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. |
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?
pandas/core/indexes/datetimelike.py
Outdated
-------- | ||
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 comment
The 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
pandas/core/indexes/datetimelike.py
Outdated
>>> 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 comment
The 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 pd.date_range
)
pandas/core/indexes/datetimelike.py
Outdated
|
||
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
@jorisvandenbossche separate issue, this should actually return an Index
here.
Codecov Report
@@ Coverage Diff @@
## master #20103 +/- ##
==========================================
- Coverage 91.72% 91.7% -0.03%
==========================================
Files 150 150
Lines 49149 49149
==========================================
- Hits 45083 45071 -12
- Misses 4066 4078 +12
Continue to review full report at Codecov.
|
thanks @Tushar987 |
Checklist for the pandas documentation sprint (ignore this if you are doing
an unrelated PR):
scripts/validate_docstrings.py <your-function-or-method>
git diff upstream/master -u -- "*.py" | flake8 --diff
python doc/make.py --single <your-function-or-method>
Please include the output of the validation script below between the "```" ticks:
If the validation script still gives errors, but you think there is a good reason
to deviate in this case (and there are certainly such cases), please state this
explicitly.
Checklist for other PRs (remove this part if you are doing a PR for the pandas documentation sprint):