xarray.DataArray.dt.strftime#
- DataArray.dt.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' ()> Size: 8B array('January 01, 2000, 12:00:00 AM', dtype=object)