Return a new Variable with shifted data. Parameters ---------- shifts : mapping of the form {dim: offset} Integer offset to shift along each of the given dimensions. Positive offsets shift to the right; negative offsets shift to the
(self, shifts=None, fill_value=dtypes.NA, **shifts_kwargs)
| 1200 | return self._replace(data=data) |
| 1201 | |
| 1202 | def shift(self, shifts=None, fill_value=dtypes.NA, **shifts_kwargs): |
| 1203 | """ |
| 1204 | Return a new Variable with shifted data. |
| 1205 | |
| 1206 | Parameters |
| 1207 | ---------- |
| 1208 | shifts : mapping of the form {dim: offset} |
| 1209 | Integer offset to shift along each of the given dimensions. |
| 1210 | Positive offsets shift to the right; negative offsets shift to the |
| 1211 | left. |
| 1212 | fill_value : scalar, optional |
| 1213 | Value to use for newly missing values |
| 1214 | **shifts_kwargs |
| 1215 | The keyword arguments form of ``shifts``. |
| 1216 | One of shifts or shifts_kwargs must be provided. |
| 1217 | |
| 1218 | Returns |
| 1219 | ------- |
| 1220 | shifted : Variable |
| 1221 | Variable with the same dimensions and attributes but shifted data. |
| 1222 | """ |
| 1223 | shifts = either_dict_or_kwargs(shifts, shifts_kwargs, "shift") |
| 1224 | result = self |
| 1225 | for dim, count in shifts.items(): |
| 1226 | result = result._shift_one_dim(dim, count, fill_value=fill_value) |
| 1227 | return result |
| 1228 | |
| 1229 | def _pad_options_dim_to_index( |
| 1230 | self, |