home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 318932648

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/pull/1496#issuecomment-318932648 https://api.github.com/repos/pydata/xarray/issues/1496 318932648 MDEyOklzc3VlQ29tbWVudDMxODkzMjY0OA== 1217238 2017-07-30T21:57:51Z 2017-07-30T21:57:51Z MEMBER

How difficult would it be to include np.where's option to provide values for both where the condition is met and where it isn't?

That works, too, e.g., In [6]: a.where(a.x + a.y < 5, -a) Out[6]: <xarray.DataArray (x: 5, y: 5)> array([[ 0, 1, 2, 3, 4], [ 5, 6, 7, 8, -9], [ 10, 11, 12, -13, -14], [ 15, 16, -17, -18, -19], [ 20, -21, -22, -23, -24]]) Dimensions without coordinates: x, y

You can even put Dataset objects in any of the arguments and it should broadcast across variables.

One annoyance is that instead of where(cond, x, y), you need to write this in the slightly counter-intuitive form x.where(cond, y). This is consistent with pandas, but we could also consider exposing the where(cond, x, y) version publicly as a function.

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