Skip to content
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

scprep.select.select_* is ambiguous with modified RangeIndex #83

Open
scottgigante opened this issue Oct 8, 2019 · 0 comments
Open

Comments

@scottgigante
Copy link
Contributor

The attempt to disambiguate between loc and iloc with pandas objects fails when the index is integer-valued.

>>> import scprep
>>> import pandas as pd
>>> X = pd.DataFrame([[0], [1], [2], [3], [4]])
>>> Y = X.iloc[[0, 2, 3]]
>>> scprep.select.select_rows(Y, idx=[0, 1])
/home/scottgigante/.local/lib/python3.7/site-packages/scprep/select.py:466: FutureWarning:
Passing list-likes to .loc or [] with any missing label will raise
KeyError in the future, you can use .reindex() as an alternative.

See the documentation here:
https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#deprecate-loc-reindex-listlike
  data = data.loc[idx]
     0
0  0.0
1  NaN

Desired output would be to treat [0,1] as an attempt to iloc.

Worse still is the case when indices are not missing, but out of order. What is the desired output of the following? An ambiguity warning, probably.

>>> Y = X.iloc[[0, 2, 1, 3]]
>>> Y
   0
0  0
2  2
1  1
3  3
>>> scprep.select.select_rows(Y, idx=[0,1])
   0
0  0
1  1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant