Skip to content

ENH: support coordinate access for indexing #7138

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

Closed
jreback opened this issue May 15, 2014 · 8 comments
Closed

ENH: support coordinate access for indexing #7138

jreback opened this issue May 15, 2014 · 8 comments
Labels
API Design Closing Candidate May be closeable, needs more eyeballs Indexing Related to indexing on series/frames, not to indexes themselves

Comments

@jreback
Copy link
Contributor

jreback commented May 15, 2014

df.iloc[[0,1],[0,1]] means return the square 0-1 rows and 0-1 columns

might be nice to have a way to mean return the coordinates (0,0),(0,1)

related #7522

http://stackoverflow.com/questions/23686561/slice-a-pandas-dataframe-by-an-array-of-indices-and-column-names/23686855#23686855

@immerrr
Copy link
Contributor

immerrr commented Jul 10, 2014

panel.fancy[:, [x, y], [0, 1]] -> df, where index=[(x, 0), (y, 1)] and columns=[a, b, c]

I don't think another indexer is the answer

Well, there's not much I can fancy doing to overload getitem:

  • add an overload wrapper to ndframe in the form of an indexer panel.coord[:, [x,y], [0,1]]
  • add an overload wrapper to index expression panel.loc[pd.coord[:, [x,y], [0,1]]]
  • add an overload wrapper to index expression components panel.loc[:, pd.coord[x,y], pd.coord[0,1]]

With the second option being a syntactic variation of the first, I take it you have something like the third one in mind. I would prefer something like that, too: it's lengthier yet a lot more flexible (e.g. would allow combining coord and non-coord lookups). In fact, I proposed something like that a while ago in #6328, but that didn't seem to get public appeal.

@jreback
Copy link
Contributor Author

jreback commented Jul 10, 2014

@immerrr I remember that issue, but I didn't look in detail hah!

so if we were to expand/add to pd.IndexSlice, maybe pd.Coord or something.

I am wondering how complicated this would get

@immerrr
Copy link
Contributor

immerrr commented Jul 10, 2014

Converting spelled-out look ups to numpy flavour should not be, but supporting such numpy lookups in BlockManager code could.

@jreback
Copy link
Contributor Author

jreback commented Jul 10, 2014

I don't think we need to be a slave to numpy

@immerrr
Copy link
Contributor

immerrr commented Jul 10, 2014

As long as pandas containers are built on top of np.ndarray it's simply a matter of convenience (and programmer's laziness).

@jreback
Copy link
Contributor Author

jreback commented Jul 10, 2014

no, what i mean is fundamentally pandas is much more flexible, so we have to have a more general soln to things like indexing (which means its more complicated). Since already support location, positional, boolean masking in single dimensions, we are contemplating adding a multi-dimensional indexer (that could be any of the above).

@jreback
Copy link
Contributor Author

jreback commented Jul 18, 2014

http://stackoverflow.com/questions/24833130/how-can-i-select-a-specific-column-from-each-row-in-a-pandas-dataframe

This is the .lookup method essentially.

maybe ought to just turn this into an indexer

df.lookup[(0,'a'),(2,'b')] ?

@jreback jreback modified the milestones: 0.16.0, Next Major Release Mar 6, 2015
@jreback jreback modified the milestones: 2.0, Next Major Release Sep 15, 2016
@jreback jreback added Future and removed Future labels Mar 16, 2017
@datapythonista datapythonista modified the milestones: 2.0, Someday Jul 8, 2018
@jbrockmendel
Copy link
Member

we have lookup, i think this can be closed

@jbrockmendel jbrockmendel added the Closing Candidate May be closeable, needs more eyeballs label Sep 22, 2020
@jreback jreback closed this as completed Jan 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Closing Candidate May be closeable, needs more eyeballs Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

No branches or pull requests

5 participants