Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -5433,7 +5433,7 @@ def _unstack_once(
if name not in index_vars:
if dim in var.dims:
if isinstance(fill_value, Mapping):
fill_value_ = fill_value[name]
fill_value_ = fill_value.get(name, xrdtypes.NA)
else:
fill_value_ = fill_value

Expand Down
4 changes: 4 additions & 0 deletions xarray/tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -4150,6 +4150,10 @@ def test_unstack_fill_value(self) -> None:
expected3 = ds.unstack("index").fillna({"var": -1, "other_var": 1}).astype(int)
assert_equal(actual3, expected3)

actual4 = ds.unstack("index", fill_value={"var": -1})
expected4 = ds.unstack("index").fillna({"var": -1, "other_var": np.nan})
assert_equal(actual4, expected4)

@requires_sparse
def test_unstack_sparse(self) -> None:
ds = xr.Dataset(
Expand Down
Loading