Skip to content

Custom fill value for align, reindex and reindex_like #2876

Closed
@shoyer

Description

@shoyer

It would be nice to be able to specify a custom fill value other than NaN for alignment/reindexing, e.g.,

>>> xr.DataArray([0, 0], [('x', [1, 2])]).reindex(x=[0, 1, 2, 3], fill_value=-1)
<xarray.DataArray (x: 4)>
array([-1, 0, 0, -1])
Coordinates:
  * x        (x) int64 1 2 3 4

This should be pretty straightforward, simplify a matter of adding a fill_value keyword argument to the various interfaces and passing it on to Variable.__getitem_with_mask inside xarray.core.alignment.reindex_variables().

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions