Concise way to filter data in xarray

前端 未结 2 878
眼角桃花
眼角桃花 2021-02-13 22:59

I need to apply a very simple \'match statement\' to the values in an xarray array:

  1. Where the value > 0, make 2
  2. Where the value == 0, make 0
  3. Wher
2条回答
  •  一个人的身影
    2021-02-13 23:16

    xarray now supports .where(condition, other), so this is now valid:

    result = date_by_items.where(date_by_items > 0, 2)
    

提交回复
热议问题