ENH: support Ellipsis in loc/iloc by jbrockmendel · Pull Request #37750 · pandas-dev/pandas (original) (raw)

I personally don't see myself using it, but the arguments of @shoyer on the issue certainly make sense (although they are from a time we still had multidimensional dataframes (>2d) I think)

Now, if adding it, this will need some docs.

Also, I think we would need some some more test cases?
Eg df.loc[..., ...] (in numpy this errors about "an index can only have a single ellipsis ('...')")
Or series.loc[...], or df.loc[..., 1, 2], ...

In numpy, arr[.., 1] and arr[1] actually do something different on a 1D array (numpy scalar vs 0d array; now we don't have this difference in pandas, so that's probably not an issue)

MI cases are appreciably more complicated and im planning to handle them separately

Do you mean having an Ellipsis "within" the indexer for the MultiIndexes axis?
That's indeed certainly a different topic, but just having an Ellipsis when indexing a dataframe with a MultiIndex can be tested here, I think, as it is already covered by your changes (I assume). Eg the same tests as you have now, like df.loc[..., [1]] but on a DataFrame with a MI (I suppose this doesn't take a different code path necessarily, as it just expands to a null slice, but still good to explicitly have tests with different index types I think)