File tree Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -5433,7 +5433,7 @@ def _unstack_once(
54335433 if name not in index_vars :
54345434 if dim in var .dims :
54355435 if isinstance (fill_value , Mapping ):
5436- fill_value_ = fill_value [ name ]
5436+ fill_value_ = fill_value . get ( name , xrdtypes . NA )
54375437 else :
54385438 fill_value_ = fill_value
54395439
Original file line number Diff line number Diff line change @@ -4150,6 +4150,10 @@ def test_unstack_fill_value(self) -> None:
41504150 expected3 = ds .unstack ("index" ).fillna ({"var" : - 1 , "other_var" : 1 }).astype (int )
41514151 assert_equal (actual3 , expected3 )
41524152
4153+ actual4 = ds .unstack ("index" , fill_value = {"var" : - 1 })
4154+ expected4 = ds .unstack ("index" ).fillna ({"var" : - 1 , "other_var" : np .nan })
4155+ assert_equal (actual4 , expected4 )
4156+
41534157 @requires_sparse
41544158 def test_unstack_sparse (self ) -> None :
41554159 ds = xr .Dataset (
You can’t perform that action at this time.
0 commit comments