home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 642039530

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
642039530 MDU6SXNzdWU2NDIwMzk1MzA= 4165 allow specifying a fill value per variable 14808389 closed 0     1 2020-06-19T15:08:16Z 2020-08-24T22:03:15Z 2020-08-24T22:03:15Z MEMBER      

While working on #4163 I noticed that the fill value parameter for align (but maybe also reindex, concat, merge and combine_*?) will be used for all variables (except dimension coordinates) which is obviously not ideal when working with quantities. Would it make sense to optionally allow fill_value to be a dict which maps a fill value to a variable name?

Consider this: python In [2]: a = xr.Dataset( ...: data_vars={"a": ("x", [12, 14, 13, 10, 8])}, ...: coords={"x": [-2, -1, 0, 1, 2], "u": ("x", [-20, -10, 0, 10, 20])}, ...: ) ...: b = xr.Dataset( ...: data_vars={"b": ("x", [7, 9, 3])}, ...: coords={"x": [0, 3, 4], "u": ("x", [0, 30, 40])}, ...: ...: ) ...: ...: xr.align(a, b, join="outer", fill_value=-50) Out[2]: (<xarray.Dataset> Dimensions: (x: 7) Coordinates: * x (x) int64 -2 -1 0 1 2 3 4 u (x) int64 -20 -10 0 10 20 -50 -50 Data variables: a (x) int64 12 14 13 10 8 -50 -50, <xarray.Dataset> Dimensions: (x: 7) Coordinates: * x (x) int64 -2 -1 0 1 2 3 4 u (x) int64 -50 -50 0 -50 -50 30 40 Data variables: b (x) int64 -50 -50 7 -50 -50 9 3) I'd like to be able to do something like this instead: python In [3]: xr.align(a, b, join="outer", fill_value={"a": -30, "b": -40, "u": -50}) Out[3]: (<xarray.Dataset> Dimensions: (x: 7) Coordinates: * x (x) int64 -2 -1 0 1 2 3 4 u (x) int64 -20 -10 0 10 20 -50 -50 Data variables: a (x) int64 12 14 13 10 8 -30 -30, <xarray.Dataset> Dimensions: (x: 7) Coordinates: * x (x) int64 -2 -1 0 1 2 3 4 u (x) int64 -40 -40 0 -40 -40 30 40 Data variables: b (x) int64 -50 -50 7 -50 -50 9 3)

I could get there by passing the default (dtypes.NA) and then using fillna, but that only seems to work with data variables so coordinates would need to pass through a reset_coords / set_coords cycle. Also, with this the dtype is changed to float.

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/4165/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
  • 1 row from issue in issue_comments
Powered by Datasette · Queries took 0.997ms · About: xarray-datasette