MCPcopy Index your code
hub / github.com/pydata/xarray / _round_field

Function _round_field

xarray/core/accessor_dt.py:170–197  ·  view source on GitHub ↗

Indirectly access rounding functions by wrapping data as a Series or CFTimeIndex Parameters ---------- values : np.ndarray or dask.array-like Array-like container of datetime-like values name : {"ceil", "floor", "round"} Name of rounding function freq : str

(values, name, freq)

Source from the content-addressed store, hash-verified

168
169
170def _round_field(values, name, freq):
171 """Indirectly access rounding functions by wrapping data
172 as a Series or CFTimeIndex
173
174 Parameters
175 ----------
176 values : np.ndarray or dask.array-like
177 Array-like container of datetime-like values
178 name : {"ceil", "floor", "round"}
179 Name of rounding function
180 freq : str
181 a freq string indicating the rounding resolution
182
183 Returns
184 -------
185 rounded timestamps : same type as values
186 Array-like of datetime fields accessed for each element in values
187
188 """
189 if is_duck_dask_array(values):
190 from dask.array import map_blocks
191
192 dtype = np.datetime64 if is_np_datetime_like(values.dtype) else np.dtype("O")
193 return map_blocks(
194 _round_through_series_or_index, values, name, freq=freq, dtype=dtype
195 )
196 else:
197 return _round_through_series_or_index(values, name, freq)
198
199
200def _strftime_through_cftimeindex(values, date_format: str):

Callers 1

_tslib_round_accessorMethod · 0.85

Calls 5

is_duck_dask_arrayFunction · 0.90
is_np_datetime_likeFunction · 0.90
map_blocksFunction · 0.90
dtypeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…