issue_comments: 1490313819
This data as json
html_url | issue_url | id | node_id | user | created_at | updated_at | author_association | body | reactions | performed_via_github_app | issue |
---|---|---|---|---|---|---|---|---|---|---|---|
https://github.com/pydata/xarray/issues/6431#issuecomment-1490313819 | https://api.github.com/repos/pydata/xarray/issues/6431 | 1490313819 | IC_kwDOAMm_X85Y1GJb | 61923007 | 2023-03-30T13:33:09Z | 2023-03-30T13:33:09Z | NONE | @TomNicholas, I believe the pad() method does not consider any coordinates and only pads the data along the dimensions it contains. That's why the padding leads to a new data array that has the same dimension name as the original one but no coordinates. We can set the coordinates explicitly using the da = xr.DataArray(np.arange(9), dim='x') padded_da = da.pad({'x': (0, 1)}, 'constant') padded_da.coords['x'] = np.arange(padded_da.shape[0]) print(padded_da) <xarray.DataArray (x: 3)> array([ 0., 1., nan]) Coordinates: * x (x) int64 0 1 2 ``` Hopefully this helps! |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1188523721 |