MCPcopy
hub / github.com/pydata/xarray / strftime

Method strftime

xarray/core/accessor_dt.py:354–385  ·  view source on GitHub ↗

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 <https://docs.python.org/3/library/datetime.html#strftime-strpt

(self, date_format: str)

Source from the content-addressed store, hash-verified

352 """
353
354 def strftime(self, date_format: str) -> T_DataArray:
355 """
356 Return an array of formatted strings specified by date_format, which
357 supports the same string format as the python standard library. Details
358 of the string format can be found in `python string format doc
359 <https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior>`__
360
361 Parameters
362 ----------
363 date_format : str
364 date format string (e.g. "%Y-%m-%d")
365
366 Returns
367 -------
368 formatted strings : same type as values
369 Array-like of strings formatted for each element in values
370
371 Examples
372 --------
373 >>> import datetime
374 >>> rng = xr.Dataset({"time": datetime.datetime(2000, 1, 1)})
375 >>> rng["time"].dt.strftime("%B %d, %Y, %r")
376 <xarray.DataArray 'strftime' ()> Size: 8B
377 array('January 01, 2000, 12:00:00 AM', dtype=object)
378 """
379 obj_type = type(self._obj)
380
381 result = _strftime(self._obj.data, date_format)
382
383 return obj_type(
384 result, name="strftime", coords=self._obj.coords, dims=self._obj.dims
385 )
386
387 def isocalendar(self) -> Dataset:
388 """Dataset containing ISO year, week number, and weekday.

Callers 1

_strftime_through_seriesFunction · 0.45

Calls 2

typeFunction · 0.85
_strftimeFunction · 0.85

Tested by

no test coverage detected