issue_comments: 1295372811
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/7211#issuecomment-1295372811 | https://api.github.com/repos/pydata/xarray/issues/7211 | 1295372811 | IC_kwDOAMm_X85NNdIL | 64480652 | 2022-10-28T19:26:45Z | 2022-10-28T19:41:36Z | NONE | Hey @TomNicholas, thanks for replying me back! The problem is they chose to define how to hash a list (which is no hashable) by parsing it to a tuple ```python class frozenlist(list): def readonly(self, args, *kwargs): raise RuntimeError("Cannot modify ReadOnlyList")
``` Dataset class defines getitem by
It tries to hash the key (and this frozenlist do this without any error). I've checked out how pandas library deal with this task. They have a much more complex structure to deal with this problem (I haven't read all of the code below to understand): ```python def getitem(self, key): check_deprecated_indexers(key) key = lib.item_from_zerodim(key) key = com.apply_if_callable(key, self)
``` This similar code, by the way, runs correctly ```python %%import pandas as pd data = pd.DataFrame({'a': [1], 'b': [2]}) variables = frozenlist(['a']) data[variables] ``` Now it is a matter of how xarray want to treat this issue. If you do want to change your way of doing this, I could try coding and request this PR trying pandas approach. Anyway, I will report this issue back to Dagster for them to check this discussion too. Maybe they see their side is worth changing. Let me know what is your view about this! Links: https://github.com/pydata/xarray/blob/e1936a98059ae29da2861f58a7aff4a56302aac1/xarray/core/dataset.py#L1419 https://github.com/pandas-dev/pandas/blob/v1.5.1/pandas/core/frame.py#L473-L11983 |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1422460071 |