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/2183#issuecomment-391946696,https://api.github.com/repos/pydata/xarray/issues/2183,391946696,MDEyOklzc3VlQ29tbWVudDM5MTk0NjY5Ng==,1217238,2018-05-25T05:36:57Z,2018-05-25T05:36:57Z,MEMBER,"We might need to take a look at how `where` with `drop=True` is implemented internally to see if this is feasible, but I agree that in principle there is no reason to convert from int to float in that case.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,326344778
https://github.com/pydata/xarray/issues/2183#issuecomment-391910422,https://api.github.com/repos/pydata/xarray/issues/2183,391910422,MDEyOklzc3VlQ29tbWVudDM5MTkxMDQyMg==,6815844,2018-05-25T01:03:04Z,2018-05-25T01:03:04Z,MEMBER,"Reopening as I think we need to discuss this behavior more deeply.
The similar thing happens if we pass `drop=True`,
```python
In [9]: test_ds.where(test_ds['var1'] == 1)
Out[9]:
Dimensions: (dim_0: 5)
Dimensions without coordinates: dim_0
Data variables:
var1 (dim_0) float64 nan 1.0 nan nan nan
var2 (dim_0) float64 nan 1.0 nan nan nan
In [10]: test_ds.where(test_ds['var1'] == 1, drop=True)
Out[10]:
Dimensions: (dim_0: 1)
Dimensions without coordinates: dim_0
Data variables:
var1 (dim_0) float64 1.0
var2 (dim_0) float64 1.0
```
I think that if with `drop=False`, the output dtype should be float even if all the items satisfies the condition.
It makes the behavior consistent among the cases where the conditions are met or not.
My question, may be we need to discuss more, is `drop=True` case.
In this case, there are never nan for any condition.
Do we need to convert the dtype?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,326344778
https://github.com/pydata/xarray/issues/2183#issuecomment-391909283,https://api.github.com/repos/pydata/xarray/issues/2183,391909283,MDEyOklzc3VlQ29tbWVudDM5MTkwOTI4Mw==,6815844,2018-05-25T00:54:31Z,2018-05-25T00:54:31Z,MEMBER,"Thanks for the report.
I agree this is somehow unintuitive, but it is an intended behavior.
The reason is that `np.nan` is float.
Similar with your example
```python
In [7]: test_ds.where(test_ds['var2'] == 2)['var1']
Out[7]:
array([nan, nan, nan, nan, nan])
Dimensions without coordinates: dim_0
```
where nan is used to indicate where the condition is not satified.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,326344778