home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 187393785

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
187393785 MDU6SXNzdWUxODczOTM3ODU= 1081 Transpose some but not all dimensions 6420873 closed 0     17 2016-11-04T17:31:38Z 2019-10-29T19:16:58Z 2019-10-29T19:16:58Z NONE      

Hi, all

Sorry to bother. Maybe it is a kind of stupid question for others, but I cannot figure it out at this moment.

I want to swap dims in xarray, like swapaxes in numpy. I found both dataarray and dataset has method swap_dims, but I don't understand its arguments: dims_dict : dict-like Dictionary whose keys are current dimension names and whose values are new names. Each value must already be a coordinate on this array.

Here is my example: data = np.random.rand(4,3) lon = [1,2,3] lat = [4,3,2,1] foo = xr.DataArray(data,coords=[lat,lon]) foo foo = xr.DataArray(data,coords=[lat,lon],dims=['lat','lon']) foo foo.swap_dims({'lat':'lon'}) The error message: ```


ValueError Traceback (most recent call last) <ipython-input-47-c8aa4311b27e> in <module>() ----> 1 foo.swap_dims({'lat':'lon'})

/glade/u/home/che43/miniconda2/lib/python2.7/site-packages/xarray/core/dataarray.pyc in swap_dims(self, dims_dict) 794 Dataset.swap_dims 795 """ --> 796 ds = self._to_temp_dataset().swap_dims(dims_dict) 797 return self._from_temp_dataset(ds) 798

/glade/u/home/che43/miniconda2/lib/python2.7/site-packages/xarray/core/dataset.pyc in swap_dims(self, dims_dict, inplace) 1293 raise ValueError('replacement dimension %r is not a 1D ' 1294 'variable along the old dimension %r' -> 1295 % (v, k)) 1296 1297 result_dims = set(dims_dict.get(dim, dim) for dim in self.dims)

ValueError: replacement dimension 'lon' is not a 1D variable along the old dimension 'lat' ```

Sorry to bother.

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/1081/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

  • 0 rows from issues_id in issues_labels
  • 17 rows from issue in issue_comments
Powered by Datasette · Queries took 0.614ms · About: xarray-datasette