๐Ÿพ Xarray is now 10 years old! ๐ŸŽ‰

xarray.core.accessor_dt.DatetimeAccessor.strftime

xarray.core.accessor_dt.DatetimeAccessor.strftime#

DatetimeAccessor.strftime(date_format)[source]#

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 (same type as values) โ€“ Array-like of strings formatted for each element in 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)