Xarray: `flatten` as convinience method for stack all?

Created on 3 Oct 2016  路  6Comments  路  Source: pydata/xarray

There is a bunch of operations that need to be conducted on a 1D array. It could be handy to have a convinience method that mimicks numpys flatten, i.e. works along the lines:

def flatten(dataarray, name='stacked'):
    return dataarray.stack(**{name: dataarray.dims})

What do you think?

API design enhancement good first issue help wanted

Most helpful comment

Solved by .stack=[...]?

All 6 comments

Yes, seems like a great idea to me!

This is a good idea, any reason not to add linear indexing with array.flat[:] as well?

In order to maintain a list of currently relevant issues, we mark issues as stale after a period of inactivity
If this issue remains relevant, please comment here; otherwise it will be marked as closed automatically

We might call this stack_all() instead -- that's closer to .stack() with alphabetical sorting.

Solved by .stack=[...]?

Yes indeed, good catch.

Closed by #3826

Was this page helpful?
0 / 5 - 0 ratings