Skip to content

concat: Set dimension name, if set in provided DataArray. #1812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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/combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def _calc_concat_dim_coord(dim):
coord = as_variable(dim).to_index_variable()
dim, = coord.dims
else:
coord = dim
coord = dim.rename({dim.dims[0]: dim.name})
dim, = coord.dims
return dim, coord

Expand Down
8 changes: 8 additions & 0 deletions xarray/tests/test_combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,14 @@ def test_concat_multiindex(self):
assert expected.equals(actual)
assert isinstance(actual.x.to_index(), pd.MultiIndex)

def test_concat_dim_name(self):
da = [DataArray(np.random.randn(3), dims=['d1']) for aa in range(5)]
labels = ['foo1', 'foo2', 'foo3', 'foo4', 'foo5']
daconcat = concat(da, DataArray(labels, name='stat'))
pdconcat = concat(da, pd.Index(labels, name='stat'))

self.assertDataArrayEqual(daconcat, pdconcat)


class TestConcatDataArray(TestCase):
def test_concat(self):
Expand Down