home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 487999904

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/2931#issuecomment-487999904 https://api.github.com/repos/pydata/xarray/issues/2931 487999904 MDEyOklzc3VlQ29tbWVudDQ4Nzk5OTkwNA== 35968931 2019-04-30T15:32:18Z 2019-04-30T15:32:18Z MEMBER

So in xarray coordinates which have the same name as dimensions are given special status - they are known as "dimension coordinates". (Yes this is confusing and I think there are plans to make this structure clearer in the future.)

Dimension coordinates have to be 1D along the corresponding dimension, as indicated by the error message. However in your example you didn't specify the dimension which you want the coordinate tt1 to have, because you didn't put it in a tuple with the desired dimensions like you did with the variable var1. If you add the desired dimension in then the error is no longer thrown, and I think gives you the dataset you want:

```python import xarray as xr import pandas as p import numpy as np

var1 = np.ones((364)) tt1=p.date_range('1/1/2018','12/30/2018') tt1.name= 'time1_name'

var=xr.Dataset( data_vars={ 'var1':(('mytime1'),var1), }, coords={ 'mytime1':(('mytime1'), tt1), } ) ``` which when printed gives

<xarray.Dataset> Dimensions: (mytime1: 364) Coordinates: * mytime1 (mytime1) datetime64[ns] 2018-01-01 2018-01-02 ... 2018-12-30 Data variables: var1 (mytime1) float64 1.0 1.0 1.0 1.0 1.0 1.0 ... 1.0 1.0 1.0 1.0 1.0

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