[Python-ideas] PEP pre-draft: Support for indexing with keyword arguments

Stefano Borini stefano.borini at ferrara.linux.it
Fri Jul 4 23:41:44 CEST 2014


On 7/4/14 11:07 PM, Ethan Furman wrote:
> Isn't that the standard way slices are supposed to be used though?
> Instead of integers Panda is allowing strings.  How would Pandas use the
> new feature?

It would not. Pandas is using it to use labels as indexes. adding 
keywords would allow to name the axes. These are two completely 
different use cases.

For example, one could have a table containing the temperature
with the city on one axis and the time on the other axis.

So one could have

temperature["London", 12]

Pandas would have text indexes for "London", "New York", "Chicago" and 
so on. One could say

temperature["London":"Chicago", 12]

to get the temperature of the cities between "London" and "Chicago" at noon.

The PEP would allow instead to name the axes in the query

temperature[city="London":"Chicago", hour=12]



More information about the Python-ideas mailing list