home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 493249273

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/issues/2969#issuecomment-493249273 https://api.github.com/repos/pydata/xarray/issues/2969 493249273 MDEyOklzc3VlQ29tbWVudDQ5MzI0OTI3Mw== 2448579 2019-05-16T22:10:32Z 2019-05-16T22:10:32Z MEMBER
  1. This has been reported before e.g. #1234 . I think we need a kwarg to control this behaviour. You can avoid this here by making dateVar a coordinate which seems logical in this case. ds = ds.rename({'dateVar': 'time'}).set_coords('time')

  2. This is because where fills in NaNs which is not representable by variables with int datatype. So xarray casts the variable to float. I guess we could avoid this when drop=True but not when drop=False. You can fix this partially by setting indexVar to be a co-ordinate which again seems logical in this case.

``` ds = (ds.rename({'dateVar': 'time', 'indexVar': 'N'}) .set_coords(['time', 'N']))

print(ds)

ds.where(ds.N > 50, drop=True) ```

gives me

``` <xarray.Dataset> Dimensions: (N: 100, time: 120) Coordinates: * N (N) int64 0 1 2 3 4 5 6 7 8 9 10 ... 90 91 92 93 94 95 96 97 98 99 * time (time) datetime64[ns] 2005-02-01 2005-02-02 ... 2005-05-31 Data variables: floatVar (time, N) float64 0.2382 0.9297 0.5391 ... 0.9527 0.6448 0.08718 intVar (time, N) int64 9 5 7 9 9 3 3 2 2 8 4 1 ... 8 9 1 8 1 8 9 5 7 4 4

<xarray.Dataset> Dimensions: (N: 49, time: 120) Coordinates: * N (N) int64 51 52 53 54 55 56 57 58 59 ... 92 93 94 95 96 97 98 99 * time (time) datetime64[ns] 2005-02-01 2005-02-02 ... 2005-05-31 Data variables: floatVar (time, N) float64 0.5974 0.09831 0.3858 ... 0.9527 0.6448 0.08718 intVar (time, N) float64 3.0 8.0 7.0 5.0 4.0 4.0 ... 9.0 5.0 7.0 4.0 4.0 ```

intVar has still been converted to float so you'll need to fix that manually.

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