Skip to content

Commit 7230991

Browse files
Tushar987jreback
authored andcommitted
Doc: Update the DatetimeIndex.strftime docstring (#20103)
1 parent 21ae073 commit 7230991

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

pandas/core/indexes/datetimelike.py

+25-2
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,41 @@ def strftime(self, date_format):
6161
return np.asarray(self.format(date_format=date_format),
6262
dtype=compat.text_type)
6363
strftime.__doc__ = """
64+
Convert to string array using specified date_format.
65+
6466
Return an array of formatted strings specified by date_format, which
6567
supports the same string format as the python standard library. Details
6668
of the string format can be found in `python string format doc <{0}>`__
6769
6870
Parameters
6971
----------
7072
date_format : str
71-
date format string (e.g. "%Y-%m-%d")
73+
Date format string (e.g. "%Y-%m-%d").
7274
7375
Returns
7476
-------
75-
ndarray of formatted strings
77+
numpy.ndarray
78+
NumPy array of formatted strings
79+
80+
See Also
81+
--------
82+
pandas.to_datetime : Convert the given argument to datetime
83+
DatetimeIndex.normalize : Return DatetimeIndex with times to midnight.
84+
DatetimeIndex.round : Round the DatetimeIndex to the specified freq.
85+
DatetimeIndex.floor : Floor the DatetimeIndex to the specified freq.
86+
87+
Examples
88+
--------
89+
>>> import datetime
90+
>>> data = pd.date_range(datetime.datetime(2018,3,10,19,27,52),
91+
... periods=4, freq='B')
92+
>>> df = pd.DataFrame(data, columns=['date'])
93+
>>> df.date[1]
94+
Timestamp('2018-03-13 19:27:52')
95+
>>> df.date[1].strftime('%d-%m-%Y')
96+
'13-03-2018'
97+
>>> df.date[1].strftime('%B %d, %Y, %r')
98+
'March 13, 2018, 07:27:52 PM'
7699
""".format("https://docs.python.org/3/library/datetime.html"
77100
"#strftime-and-strptime-behavior")
78101

0 commit comments

Comments
 (0)