Skip to content

Removing dimensions from Dataset objects #1949

Closed
@brynpickering

Description

@brynpickering
test_dataset = xr.Dataset(dict(
    empty_array=xr.DataArray([], dims='a'), 
    populated_array=xr.DataArray([1], {'b':['1']}, 'b')
))

I have a dataset that is produced programatically and can at times end up producing an empty DataArray. This isn't an issue, per-se, because I can remove those empty DataArrays later. However, I cannot find any way in which to remove the unused, empty dimension! I've tried deleting, dropping, resetting indeces, etc., and have had no luck in purging this empty dimension. It causes issues down the line as existence of entries in the dimensions list triggers certain events.

Is there a way to remove a dimension (and possibly then all data variables which depend on it)?

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