import pandas as pd ind = ['A', 'A', 'B', 'C']i df = pd.DataFrame({'test':range(len(ind))}, index=ind) rows = ['C', 'B'] res = df.ix[rows] assert rows == list(res.index) # fails
The problem is that the resulting DataFrame keeps the ordering of the df.index
and not the rows
key. You'll notice that the rows
key doesn't reference a duplicate value.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4