home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 442680467

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/1603#issuecomment-442680467 https://api.github.com/repos/pydata/xarray/issues/1603 442680467 MDEyOklzc3VlQ29tbWVudDQ0MjY4MDQ2Nw== 1217238 2018-11-29T02:15:48Z 2018-11-29T02:19:06Z MEMBER

That said, I still don't know how to use public MultiIndex methods for this. Neither index.get_loc_level([1, 2], level=1) nor index.get_loc((slice(None), [1, 2])) work.

The answer is the index.get_locs() method: index.get_locs([slice(None), 1, 2]]) works.

It's painfully slow for large numbers of points due to a Python loop over each point, but presumably that could be optimized: x = np.arange(10000) index = pd.MultiIndex.from_arrays([x]) %timeit index.get_locs((x,)) # 1.31 s per loop %timeit index.levels[0].get_indexer(x) # 93 µs per loop

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