Skip to content

combine_first doesn't fill empty strings #10280

Open
@jpdehollain

Description

@jpdehollain

What happened?

If a data variable elements are string types, the default empty value is an empty string ''. When I use combine_first to try to fill some empty strings in a data variable, the method doesn't fill them.

What did you expect to happen?

Elements with empty strings should be filled with non-empty strings from the other dataset.

Minimal Complete Verifiable Example

ds1 = xr.DataArray(['a','',''], dims='dim', coords={'dim': [1,2,3]})
ds2 = xr.DataArray(['b'], dims='dim', coords={'dim': [2]})
ds1.combine_first(ds2)

MVCE confirmation

  • Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
  • Complete example — the example is self-contained, including all data and the text of any traceback.
  • Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
  • New issue — a search of GitHub Issues suggests this is not a duplicate.
  • Recent environment — the issue occurs with the latest version of xarray and its dependencies.

Relevant log output

Anything else we need to know?

No response

Environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds triageIssue that has not been reviewed by xarray team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions