home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 154149878

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/645#issuecomment-154149878 https://api.github.com/repos/pydata/xarray/issues/645 154149878 MDEyOklzc3VlQ29tbWVudDE1NDE0OTg3OA== 1217238 2015-11-05T18:46:32Z 2015-11-05T18:46:32Z MEMBER

Do you know why this line https://github.com/xray/xray/blob/master/xray/core/indexing.py#L400 isn't just value?

This line is basically there to work around cases where pandas stores an array in an index with a different dtype. For example, consider this dataset with an int32 coordinate:

In [10]: xray.Dataset({'x': np.arange(3, dtype='int32')}).x.dtype Out[10]: dtype('int32')

Under the covers, there's an int64 index (pandas doesn't have Int32Index):

In [11]: xray.Dataset({'x': np.arange(3, dtype='int32')}).indexes['x'] Out[11]: Int64Index([0, 1, 2], dtype='int64', name=u'x')

This line ensure that we cast back to the original dtype when we get .values from the data.

In this case, I think a simple fix for PandasIndexAdapter would be to update it's dtype so it reports object instead of int64 if it's holding a PeriodIndex. Then the casting should work properly.

Do you know why it's trying to pull a value from the index when it prints?

I'm not entirely sure what you're referring to here -- which line(s) of code is surprising you?

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