home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 58288666

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
58288666 MDU6SXNzdWU1ODI4ODY2Ng== 326 DataArray.groupby.apply with a generic ndarray function 2002703 closed 0   987654 1 2015-02-19T23:37:34Z 2015-02-20T04:41:08Z 2015-02-20T04:41:08Z CONTRIBUTOR      

Need to apply a transformation function across one dimension of a DataArray, where that non-xray function speaks in ndarrays. Currently the only ways to do this involve wrapping the function. An example:

``` import numpy as np import xray from scipy.ndimage.morphology import binary_opening

da = xray.DataArray(np.random.random_integers(0, 1, (10, 10, 3)), dims=['row', 'col', 'time'])

I want to apply an operation the 2D image at each point in time

da.groupby('time').apply(binary_opening)

AttributeError: 'numpy.ndarray' object has no attribute 'dims'

def wrap_binary_opening(da, kwargs): return xray.DataArray(binary_opening(da.values, kwargs), da.coords)

da.groupby('time').apply(wrap_binary_opening) da.groupby('time').apply(wrap_binary_opening, iterations=2) # func may take custom args ```

My proposed solution is that apply would automatically coerce func's return value to a DataArray.

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/326/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 2 rows from issues_id in issues_labels
  • 1 row from issue in issue_comments
Powered by Datasette · Queries took 0.634ms · About: xarray-datasette