[Pandas-dev] Why is it not possible to access index entries like columns?

Joris Van den Bossche jorisvandenbossche at gmail.com
Thu Jun 15 10:15:21 EDT 2017


Hi Tyler,

I think there is agreement on that it is something we would like to change
in pandas. Related github issue is here:
https://github.com/pandas-dev/pandas/issues/8162

So as far as I can see, it is mainly someone taking up the implementation
work. There are a few API questions to be answered as well (see the
discussion in the issue).
For example, it would probably *not* be just returning
df.index.get_level_values(), but rather wrapped that in a Series (and
keeping the original index as well).
What to do when a name appears both as column name and index level name, is
another question (both on short and long term).

Very welcome to work on this if you would be interested!

Regards,
Joris

2017-06-11 22:11 GMT+02:00 Tyler Hardin <th020394 at gmail.com>:

> Hi,
>
> Is it just a matter of implementing the lookup in the . and [] operator
> methods to return df.index.get_level_values() with the argument, or is
> there some deeper reason this can't work that I'm not seeing?
>
> E.g. I want df['date'] to do df.get_level_values('date') when there is no
> date column and there is a level in the index named 'date'. Presumably,
> this would be a secondary lookup w/ columns taking precedence -- i.e. a
> 'date' column would mask a 'date' index.
>
> Thanks,
> Tyler
>
> _______________________________________________
> Pandas-dev mailing list
> Pandas-dev at python.org
> https://mail.python.org/mailman/listinfo/pandas-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pandas-dev/attachments/20170615/03ee8686/attachment-0001.html>


More information about the Pandas-dev mailing list