-
-
Notifications
You must be signed in to change notification settings - Fork 141
DataFrame.loc[] accepts list[str] #1162
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
To avoid some ambiguities from a typing perspective, we recommend using one of the following 2 patterns: df.loc[:, ['viper', 'sidewinder']]
df[['viper', 'sidewinder']] |
Those examples attempt to select columns, but |
Then use |
Yes, and is it possible for the type declarations here to support |
Actually, yes. This revealed a bug. Need to change pandas-stubs/pandas-stubs/core/frame.pyi Line 187 in 69b833c
list[Hashable] to list[HashableT]
PR with tests welcome. |
@Dr-Irv I have made the required changes. Please review and let me know if anything else is needed. Thanks! |
Describe the bug
DataFrame.loc[] should accept list[str] as stated in the pandas docs: "A list or array of labels, e.g. ['a', 'b', 'c']."
To Reproduce
Please complete the following information:
pandas-stubs
: 2.2.3.250308The text was updated successfully, but these errors were encountered: