home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 165943594

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/pull/677#issuecomment-165943594 https://api.github.com/repos/pydata/xarray/issues/677 165943594 MDEyOklzc3VlQ29tbWVudDE2NTk0MzU5NA== 5635139 2015-12-19T03:57:41Z 2015-12-19T03:57:41Z MEMBER

Yes, my last comment wasn't clear. I think it's something to do with ChainMap - dict(series) gives the expected result, but dict(ChainMap(series)) throws an error (actually two...).

Potentially because list(series) gives values (but list(df) gives the keys)?

Regardless I'll add a note in the docs for DataFrame & Panel, and the Series can wait for the moment.

``` python In [30]: series=pd.Series(pd.np.random.rand(4))

In [31]: dict(series) Out[31]: {0: 0.26874240805523286, 1: 0.3110026841777368, 2: 0.22873881434409837, 3: 0.9946345046609677}

In [34]: dict(xray.core.utils.ChainMap(series)) /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pandas/core/index.py:805: FutureWarning: scalar indexers for index type Int64Index should be integers and not floating point type(self).name),FutureWarning)


KeyError Traceback (most recent call last) /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pandas/core/series.py in getitem(self, key) 520 try: --> 521 result = self.index.get_value(self, key) 522

/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pandas/core/index.py in get_value(self, series, key) 1591 if is_float(k) and not self.is_floating(): -> 1592 raise KeyError 1593

KeyError:

During handling of the above exception, another exception occurred:

TypeError Traceback (most recent call last) <ipython-input-34-2a2c45b6f2cd> in <module>() ----> 1 dict(xray.core.utils.ChainMap(series))

/Users/maximilianroos/Dropbox/workspace/xray/xray/core/utils.py in getitem(self, key) 310 for mapping in self.maps: 311 try: --> 312 return mapping[key] 313 except KeyError: 314 pass

/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pandas/core/series.py in getitem(self, key) 545 546 # we can try to coerce the indexer (or this will raise) --> 547 new_key = self.index._convert_scalar_indexer(key,kind='getitem') 548 if type(new_key) != type(key): 549 return self.getitem(new_key)

/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pandas/core/index.py in _convert_scalar_indexer(self, key, kind) 804 warnings.warn("scalar indexers for index type {0} should be integers and not floating point".format( 805 type(self).name),FutureWarning) --> 806 return to_int() 807 808 return key

/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pandas/core/index.py in to_int() 787 ikey = int(key) 788 if ikey != key: --> 789 return self._invalid_indexer('label', key) 790 return ikey 791

/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pandas/core/index.py in _invalid_indexer(self, form, key) 942 klass=type(self), 943 key=key, --> 944 kind=type(key))) 945 946 def get_duplicates(self):

TypeError: cannot do label indexing on <class 'pandas.core.index.Int64Index'> with these indexers [0.26874240805523286] of <class 'numpy.float64'>

```

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