@@ -779,9 +779,9 @@ def sel(self, indexers=None, method=None, tolerance=None, drop=False,
779
779
DataArray.isel
780
780
781
781
"""
782
- indexers = either_dict_or_kwargs (indexers , indexers_kwargs , 'sel' )
783
782
ds = self ._to_temp_dataset ().sel (
784
- indexers = indexers , drop = drop , method = method , tolerance = tolerance )
783
+ indexers = indexers , drop = drop , method = method , tolerance = tolerance ,
784
+ ** indexers_kwargs )
785
785
return self ._from_temp_dataset (ds )
786
786
787
787
def isel_points (self , dim = 'points' , ** indexers ):
@@ -1092,22 +1092,26 @@ def expand_dims(self, dim, axis=None):
1092
1092
ds = self ._to_temp_dataset ().expand_dims (dim , axis )
1093
1093
return self ._from_temp_dataset (ds )
1094
1094
1095
- def set_index (self , append = False , inplace = False , ** indexes ):
1095
+ def set_index (self , indexes = None , append = False , inplace = False ,
1096
+ ** indexes_kwargs ):
1096
1097
"""Set DataArray (multi-)indexes using one or more existing
1097
1098
coordinates.
1098
1099
1099
1100
Parameters
1100
1101
----------
1102
+ indexes : {dim: index, ...}
1103
+ Mapping from names matching dimensions and values given
1104
+ by (lists of) the names of existing coordinates or variables to set
1105
+ as new (multi-)index.
1101
1106
append : bool, optional
1102
1107
If True, append the supplied index(es) to the existing index(es).
1103
1108
Otherwise replace the existing index(es) (default).
1104
1109
inplace : bool, optional
1105
1110
If True, set new index(es) in-place. Otherwise, return a new
1106
1111
DataArray object.
1107
- **indexes : {dim: index, ...}
1108
- Keyword arguments with names matching dimensions and values given
1109
- by (lists of) the names of existing coordinates or variables to set
1110
- as new (multi-)index.
1112
+ **indexes_kwargs: optional
1113
+ The keyword arguments form of ``indexes``.
1114
+ One of indexes or indexes_kwargs must be provided.
1111
1115
1112
1116
Returns
1113
1117
-------
@@ -1118,6 +1122,7 @@ def set_index(self, append=False, inplace=False, **indexes):
1118
1122
--------
1119
1123
DataArray.reset_index
1120
1124
"""
1125
+ indexes = either_dict_or_kwargs (indexes , indexes_kwargs , 'set_index' )
1121
1126
coords , _ = merge_indexes (indexes , self ._coords , set (), append = append )
1122
1127
if inplace :
1123
1128
self ._coords = coords
@@ -1156,25 +1161,31 @@ def reset_index(self, dims_or_levels, drop=False, inplace=False):
1156
1161
else :
1157
1162
return self ._replace (coords = coords )
1158
1163
1159
- def reorder_levels (self , inplace = False , ** dim_order ):
1164
+ def reorder_levels (self , dim_order = None , inplace = False ,
1165
+ ** dim_order_kwargs ):
1160
1166
"""Rearrange index levels using input order.
1161
1167
1162
1168
Parameters
1163
1169
----------
1170
+ dim_order : optional
1171
+ Mapping from names matching dimensions and values given
1172
+ by lists representing new level orders. Every given dimension
1173
+ must have a multi-index.
1164
1174
inplace : bool, optional
1165
1175
If True, modify the dataarray in-place. Otherwise, return a new
1166
1176
DataArray object.
1167
- **dim_order : optional
1168
- Keyword arguments with names matching dimensions and values given
1169
- by lists representing new level orders. Every given dimension
1170
- must have a multi-index.
1177
+ **dim_order_kwargs: optional
1178
+ The keyword arguments form of ``dim_order``.
1179
+ One of dim_order or dim_order_kwargs must be provided.
1171
1180
1172
1181
Returns
1173
1182
-------
1174
1183
obj : DataArray
1175
1184
Another dataarray, with this dataarray's data but replaced
1176
1185
coordinates.
1177
1186
"""
1187
+ dim_order = either_dict_or_kwargs (dim_order , dim_order_kwargs ,
1188
+ 'reorder_levels' )
1178
1189
replace_coords = {}
1179
1190
for dim , order in dim_order .items ():
1180
1191
coord = self ._coords [dim ]
@@ -1190,7 +1201,7 @@ def reorder_levels(self, inplace=False, **dim_order):
1190
1201
else :
1191
1202
return self ._replace (coords = coords )
1192
1203
1193
- def stack (self , ** dimensions ):
1204
+ def stack (self , dimensions = None , ** dimensions_kwargs ):
1194
1205
"""
1195
1206
Stack any number of existing dimensions into a single new dimension.
1196
1207
@@ -1199,9 +1210,12 @@ def stack(self, **dimensions):
1199
1210
1200
1211
Parameters
1201
1212
----------
1202
- ** dimensions : keyword arguments of the form new_name=(dim1, dim2, ...)
1213
+ dimensions : Mapping of the form new_name=(dim1, dim2, ...)
1203
1214
Names of new dimensions, and the existing dimensions that they
1204
1215
replace.
1216
+ **dimensions_kwargs:
1217
+ The keyword arguments form of ``dimensions``.
1218
+ One of dimensions or dimensions_kwargs must be provided.
1205
1219
1206
1220
Returns
1207
1221
-------
@@ -1230,7 +1244,7 @@ def stack(self, **dimensions):
1230
1244
--------
1231
1245
DataArray.unstack
1232
1246
"""
1233
- ds = self ._to_temp_dataset ().stack (** dimensions )
1247
+ ds = self ._to_temp_dataset ().stack (dimensions , ** dimensions_kwargs )
1234
1248
return self ._from_temp_dataset (ds )
1235
1249
1236
1250
def unstack (self , dim ):
@@ -1978,7 +1992,7 @@ def diff(self, dim, n=1, label='upper'):
1978
1992
ds = self ._to_temp_dataset ().diff (n = n , dim = dim , label = label )
1979
1993
return self ._from_temp_dataset (ds )
1980
1994
1981
- def shift (self , ** shifts ):
1995
+ def shift (self , shifts = None , ** shifts_kwargs ):
1982
1996
"""Shift this array by an offset along one or more dimensions.
1983
1997
1984
1998
Only the data is moved; coordinates stay in place. Values shifted from
@@ -1987,10 +2001,13 @@ def shift(self, **shifts):
1987
2001
1988
2002
Parameters
1989
2003
----------
1990
- ** shifts : keyword arguments of the form {dim: offset}
2004
+ shifts : Mapping with the form of {dim: offset}
1991
2005
Integer offset to shift along each of the given dimensions.
1992
2006
Positive offsets shift to the right; negative offsets shift to the
1993
2007
left.
2008
+ **shifts_kwargs:
2009
+ The keyword arguments form of ``shifts``.
2010
+ One of shifts or shifts_kwarg must be provided.
1994
2011
1995
2012
Returns
1996
2013
-------
@@ -2012,8 +2029,8 @@ def shift(self, **shifts):
2012
2029
Coordinates:
2013
2030
* x (x) int64 0 1 2
2014
2031
"""
2015
- variable = self .variable .shift (** shifts )
2016
- return self ._replace ( variable )
2032
+ ds = self ._to_temp_dataset () .shift (shifts = shifts , ** shifts_kwargs )
2033
+ return self ._from_temp_dataset ( ds )
2017
2034
2018
2035
def roll (self , shifts = None , roll_coords = None , ** shifts_kwargs ):
2019
2036
"""Roll this array by an offset along one or more dimensions.
0 commit comments