Return a new object with squeezed data. Parameters ---------- dim : None or str or tuple of str, optional Selects a subset of the length one dimensions. If a dimension is selected with length greater than one, an error is raised. If None,
(self, dim=None)
| 1141 | return self[key] |
| 1142 | |
| 1143 | def squeeze(self, dim=None): |
| 1144 | """Return a new object with squeezed data. |
| 1145 | |
| 1146 | Parameters |
| 1147 | ---------- |
| 1148 | dim : None or str or tuple of str, optional |
| 1149 | Selects a subset of the length one dimensions. If a dimension is |
| 1150 | selected with length greater than one, an error is raised. If |
| 1151 | None, all length one dimensions are squeezed. |
| 1152 | |
| 1153 | Returns |
| 1154 | ------- |
| 1155 | squeezed : same type as caller |
| 1156 | This object, but with with all or a subset of the dimensions of |
| 1157 | length 1 removed. |
| 1158 | |
| 1159 | See Also |
| 1160 | -------- |
| 1161 | numpy.squeeze |
| 1162 | """ |
| 1163 | dims = common.get_squeeze_dims(self, dim) |
| 1164 | return self.isel(dict.fromkeys(dims, 0)) |
| 1165 | |
| 1166 | def _shift_one_dim(self, dim, count, fill_value=dtypes.NA): |
| 1167 | axis = self.get_axis_num(dim) |