On Mon, Jul 20, 2020 at 3:17 AM Rhodri James <rhodri@kynesim.co.uk> wrote:
Ironically that example pushes me back to -1.  It may look a lot like
xarray and pandas working, but that just means it should be in xarray
and/or pandas.

after following most of this discussion, I'm still not sure what we'd get with keywords in indexing.

But I do think it would be nice of we could use slice syntax in other places. That would allow things like xarray and pandas to use slices in regular function calls. here's an example from the xarray docs:

 da.isel(space=0, time=slice(None, 2))

wouldn't that be nice as:

da.isel(space=0, time=:2)

or:

da.sel(time=slice("2000-01-01", "2000-01-02"))

could be:

da.sel(time="2000-01-01":"2000-01-02")

As far as I can tell, slicing syntax is currently a syntax error in these cases, and any others I thought to test.

Is there a reason to not allow syntax for creating a slice object to be used anywhere (Or more places, anyway)?

By the way, I just noticed this note in the xarray docs:

"""Note: We would love to be able to do indexing with labeled dimension names inside brackets, but unfortunately, Python does yet not support indexing with keyword arguments like da[space=0]
"""
So they would like it :-)
 
-CHB



--
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython