-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Labels
BugIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselves
Milestone
Description
df = pandas.DataFrame([['a'], ['b']], index=[1,2], columns=['x'])
df.loc[[3]] # does not raise KeyError as documented
"ALL of the labels for which you ask, must be in the index or a KeyError will be raised!"
http://pandas.pydata.org/pandas-docs/stable/indexing.html#selection-by-label
and
".loc is strictly label based, will raise KeyError when the items are not found":
http://pandas.pydata.org/pandas-docs/stable/indexing.html#different-choices-for-indexing-loc-iloc-and-ix
also, possibly separate bug:
df.loc[pandas.Index(['a', 'k', 'b']), : ]
DOES fail, so we have an inconsistency between .loc[values,:] and .loc[values]
Metadata
Metadata
Assignees
Labels
BugIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselves