home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 1397627848

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/7456#issuecomment-1397627848 https://api.github.com/repos/pydata/xarray/issues/7456 1397627848 IC_kwDOAMm_X85TThvI 14077947 2023-01-19T21:24:30Z 2023-01-19T21:24:30Z CONTRIBUTOR

I'm not an xarray developer, but my guess is that your argument is why positional indexing/slicing is not available for datasets.

As for the specific case of using axis parameter of expand_dims, I think this is useful for the case in which the user is either confident about the axis order in each DataArray or will use label based operations such that axis order doesn’t matter. I was curious so I did a quick comparison of the speed for using this parameter versus a subsequent transpose operation: shape = (10, 50, 100, 200) ds = xr.Dataset( { "foo": (["time", "x", "y", "z"], np.random.rand(*shape)), "bar": (["time", "x", "y", "z"], np.random.randint(0, 10, shape)), }, { "time": (["time"], np.arange(shape[0])), "x": (["x"], np.arange(shape[1])), "y": (["y"], np.arange(shape[2])), "z": (["z"], np.arange(shape[3])), }, ) %%timeit -r 4 ds1 = ds.expand_dims("sample", axis=1) 38.1 µs ± 76 ns per loop (mean ± std. dev. of 4 runs, 10,000 loops each) %%timeit -r 4 ds2 = ds.expand_dims("sample").transpose("time", "sample", "x", "y", "z") 172 µs ± 612 ns per loop (mean ± std. dev. of 4 runs, 10,000 loops each)

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  1548355645
Powered by Datasette · Queries took 1.99ms · About: xarray-datasette