home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 438370603

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/1115#issuecomment-438370603 https://api.github.com/repos/pydata/xarray/issues/1115 438370603 MDEyOklzc3VlQ29tbWVudDQzODM3MDYwMw== 5635139 2018-11-13T17:51:56Z 2018-11-13T17:51:56Z MEMBER

And one that handles NaNs:

```python

untested!

def covariance(x, y, dim=None): valid_values = x.notnull() & y.notnull() valid_count = valid_values.sum(dim)

demeaned_x = (x - x.mean(dim)).fillna(0)
demeaned_y = (y - y.mean(dim)).fillna(0)

return xr.dot(demeaned_x, demeaned_y, dims=dim) / valid_count

def correlation(x, y, dim=None): # dim should default to the intersection of x.dims and y.dims return covariance(x, y, dim) / (x.std(dim) * y.std(dim)) ```

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