Convert to Index using specified date_format. Return an Index 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 <https:/
(self, date_format: str)
| 1785 | """ |
| 1786 | |
| 1787 | def strftime(self, date_format: str) -> npt.NDArray[np.object_]: |
| 1788 | """ |
| 1789 | Convert to Index using specified date_format. |
| 1790 | |
| 1791 | Return an Index of formatted strings specified by date_format, which |
| 1792 | supports the same string format as the python standard library. Details |
| 1793 | of the string format can be found in `python string format |
| 1794 | doc <https://docs.python.org/3/library/datetime.html |
| 1795 | #strftime-and-strptime-behavior>`__. |
| 1796 | |
| 1797 | Formats supported by the C `strftime` API but not by the python string format |
| 1798 | doc (such as `"%R"`, `"%r"`) are not officially supported and should be |
| 1799 | preferably replaced with their supported equivalents (such as `"%H:%M"`, |
| 1800 | `"%I:%M:%S %p"`). |
| 1801 | |
| 1802 | Note that `PeriodIndex` support additional directives, detailed in |
| 1803 | `Period.strftime`. |
| 1804 | |
| 1805 | Parameters |
| 1806 | ---------- |
| 1807 | date_format : str |
| 1808 | Date format string (e.g. "%%Y-%%m-%%d"). |
| 1809 | |
| 1810 | Returns |
| 1811 | ------- |
| 1812 | ndarray[object] |
| 1813 | NumPy ndarray of formatted strings. |
| 1814 | |
| 1815 | See Also |
| 1816 | -------- |
| 1817 | to_datetime : Convert the given argument to datetime. |
| 1818 | DatetimeIndex.normalize : Return DatetimeIndex with times to midnight. |
| 1819 | DatetimeIndex.round : Round the DatetimeIndex to the specified freq. |
| 1820 | DatetimeIndex.floor : Floor the DatetimeIndex to the specified freq. |
| 1821 | Timestamp.strftime : Format a single Timestamp. |
| 1822 | Period.strftime : Format a single Period. |
| 1823 | |
| 1824 | Examples |
| 1825 | -------- |
| 1826 | >>> rng = pd.date_range(pd.Timestamp("2018-03-10 09:00"), periods=3, freq="s") |
| 1827 | >>> rng.strftime("%B %d, %Y, %r") |
| 1828 | Index(['March 10, 2018, 09:00:00 AM', 'March 10, 2018, 09:00:01 AM', |
| 1829 | 'March 10, 2018, 09:00:02 AM'], |
| 1830 | dtype='str') |
| 1831 | """ |
| 1832 | result = self._format_native_types(date_format=date_format, na_rep=np.nan) |
| 1833 | if using_string_dtype(): |
| 1834 | from pandas import StringDtype |
| 1835 | |
| 1836 | return pd_array(result, dtype=StringDtype(na_value=np.nan)) # type: ignore[return-value] |
| 1837 | return result.astype(object, copy=False) |
| 1838 | |
| 1839 | |
| 1840 | class TimelikeOps(DatetimeLikeArrayMixin): |