home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 616211072

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/3984#issuecomment-616211072 https://api.github.com/repos/pydata/xarray/issues/3984 616211072 MDEyOklzc3VlQ29tbWVudDYxNjIxMTA3Mg== 14808389 2020-04-19T19:24:51Z 2020-04-20T10:35:44Z MEMBER

this ultimately depends on how the last dimension of A and B are related (or rather, how you want to model the relationship). If they are not related at all, simply use different dimension names: python In [2]: da1 = xr.DataArray(np.empty(shape=(2, 5, 100)), dims=("x", "y", "z1")) ...: da2 = xr.DataArray(np.empty(shape=(2, 5, 101)), dims=("x", "y", "z2")) ...: ds = xr.Dataset({"a": da1, "b": da2}) ...: ds Out[2]: <xarray.Dataset> Dimensions: (x: 2, y: 5, z1: 100, z2: 101) Dimensions without coordinates: x, y, z1, z2 Data variables: a (x, y, z1) float64 6.901e-310 6.901e-310 4.67e-310 ... 0.0 0.0 0.0 b (x, y, z2) float64 6.901e-310 6.901e-310 4.67e-310 ... 0.0 0.0 0.0

If they are related, assign coordinates to the dimensions: python In [3]: da1 = xr.DataArray( ...: np.empty(shape=(2, 5, 100)), ...: dims=("x", "y", "z"), ...: coords={"z": np.arange(100)}, ...: ) ...: da2 = xr.DataArray( ...: np.empty(shape=(2, 5, 101)), ...: dims=("x", "y", "z"), ...: coords={"z": np.arange(101)}, ...: ) ...: ds = xr.Dataset({"a": da1, "b": da2}) ...: ds Out[3]: <xarray.Dataset> Dimensions: (x: 2, y: 5, z: 101) Coordinates: * z (z) int64 0 1 2 3 4 5 6 7 8 9 10 ... 91 92 93 94 95 96 97 98 99 100 Dimensions without coordinates: x, y Data variables: a (x, y, z) float64 6.901e-310 6.901e-310 ... 6.917e-323 nan b (x, y, z) float64 6.901e-310 6.901e-310 ... 6.901e-310 -6.35e+53 In this case, A does not have the label z=100, so it is treated as missing (you should be familiar with the concept of "missing values" since you know pandas).

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