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

Function format_times

xarray/coding/cftimeindex.py:186–208  ·  view source on GitHub ↗

Format values of cftimeindex as pd.Index.

(
    index,
    max_width,
    offset,
    separator=", ",
    first_row_offset=0,
    intermediate_row_end=",\n",
    last_row_end="",
)

Source from the content-addressed store, hash-verified

184
185
186def format_times(
187 index,
188 max_width,
189 offset,
190 separator=", ",
191 first_row_offset=0,
192 intermediate_row_end=",\n",
193 last_row_end="",
194):
195 """Format values of cftimeindex as pd.Index."""
196 n_per_row = max(max_width // (CFTIME_REPR_LENGTH + len(separator)), 1)
197 n_rows = math.ceil(len(index) / n_per_row)
198
199 representation = ""
200 for row in range(n_rows):
201 indent = first_row_offset if row == 0 else offset
202 row_end = last_row_end if row == n_rows - 1 else intermediate_row_end
203 times_for_row = index[row * n_per_row : (row + 1) * n_per_row]
204 representation += format_row(
205 times_for_row, indent=indent, separator=separator, row_end=row_end
206 )
207
208 return representation
209
210
211def format_attrs(index, separator=", "):

Callers 1

__repr__Method · 0.85

Calls 2

format_rowFunction · 0.85
ceilMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…