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 199188476,MDU6SXNzdWUxOTkxODg0NzY=,1194,Use masked arrays while preserving int,500246,open,0,,,9,2017-01-06T12:40:22Z,2020-03-29T20:37:29Z,,CONTRIBUTOR,,,,"A great beauty of numpys masked arrays is that it works with any dtype, since it does not use `nan`. Unfortunately, when I try to put my data into an `xarray.Dataset`, it converts ints to float, as shown below: ``` In [137]: x = arange(30, dtype=""i1"").reshape(3, 10) In [138]: xr.Dataset({""count"": ([""x"", ""y""], ma.masked_where(x%5>3, x))}, coords={""x"": range(3), ""y"": ...: range(10)}) Out[138]: Dimensions: (x: 3, y: 10) Coordinates: * y (y) int64 0 1 2 3 4 5 6 7 8 9 * x (x) int64 0 1 2 Data variables: count (x, y) float64 0.0 1.0 2.0 3.0 nan 5.0 6.0 7.0 8.0 nan 10.0 ... ``` This happens in the function [`_maybe_promote`](https://github.com/pydata/xarray/blob/master/xarray/core/common.py#L693). Such type “promotion” is unaffordable for me; the memory consumption of my multi-gigabyte arrays would explode by a factor 4. Secondly, many of my integer-dtype fields are bit arrays, for which floating point representation is not desirable. It would greatly benefit `xarray` if it could use masking while preserving the dtype of input data. (See also: [Stackoverflow question](http://stackoverflow.com/q/41505699/974555))","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/1194/reactions"", ""total_count"": 2, ""+1"": 2, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue