-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Index API proposal: unified axis label lookup #7651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I was trying to mock up a proof of concept (while at ep2014) and decided to start with simple things, In [19]: s = pd.Series([1,2,3], index=list('abc'))
In [20]: s.at['a']
Out[20]: 1
In [21]: s.at['b']
Out[21]: 2
In [22]: s.at['c']
Out[22]: 3
In [23]: s.at[0]
Out[23]: 1 I couldn't find any reference to this feature in pandas doc, and I have a strong feeling it shouldn't be there. @jrebac, what do you think, do I have to maintain it? |
I think that is a bug, |
Just stumbled across this -- it gets a bit +1 from me! |
cc @toobaz closing as stale, but certainly would take a PR (or more) to simplify internal indexing :> |
Just for the records, since I was cced: I'm -1 on this, for two reasons. The first is conceptual: I don't like The second is practical: there are calls to By the way, the crucial step to allow real decoupling is to enable |
As the next step of separation-of-concerns plan (#6744) I'd like to
propose adding a method (or several, actually) to
Index
class thatwould encapsulate the details of
foo.loc[l1,l2,...]
lookup.Implementation Idea
Roughly, the idea is to make
loc
's getitem as simple asNot quite, but hopefully you get the point. The default
lookup_labels_nd
implementation would then look something like this:The result should be an object that could be fed to an underlying
BlockManager to perform the requested operation. To support adding
new rows with "setitem", it is only needed to agree that
lookup_labels_nd
willnever return negative indices unless they reference newly appended
items along that axis.
This would allow to hide Index-subclass-specific lookup peculiarities
in their respective overrides of
lookup_labels_nd
andlookup_labels
(proposals forbetter names are welcome), e.g.:
Benefits
try .. catch
block carpet-catching alogic error, because corner cases will be handled precisely where
they are needed and nowhere else
alternative lookup scenarios, meaning more performance
eventually, cythonize (as a side effect of this point I'd like to try putting
up a wiki page with indexing API reference)
The text was updated successfully, but these errors were encountered: