xarray.core.accessor_dt.DatetimeAccessor.strftime¶
-
DatetimeAccessor.
strftime
(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
- Parameters
date_format (
str
) – date format string (e.g. “%Y-%m-%d”)- Returns
formatted strings – Array-like of strings formatted for each element in values
- Return type
same type as values
Examples
>>> import datetime >>> rng = xr.Dataset({"time": datetime.datetime(2000, 1, 1)}) >>> rng["time"].dt.strftime("%B %d, %Y, %r") <xarray.DataArray 'strftime' ()> array('January 01, 2000, 12:00:00 AM', dtype=object)