-
-
Notifications
You must be signed in to change notification settings - Fork 141
Extend Scalar sub-type of Index to the __iter__() method #367
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
Conversation
3190539
to
0f5c899
Compare
@@ -497,8 +497,7 @@ class DataFrame(NDFrame, OpsMixin): | |||
@overload | |||
def __getitem__( | |||
self, | |||
idx: tuple | |||
| Series[_bool] | |||
idx: Series[_bool] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x = pd.DataFrame([[1, 2, 3], [4, 5, 6], [7, 8, 9]], index=["a", "b", "c"])
0 1 2
a 1 2 3
b 4 5 6
c 7 8 9
x[[0, 1]]
works
x[(0, 1)]
does not, because that is interpreted as a column label
So it appears So I took a different approach. Went back to annotating using |
ce62af9
to
4337b8d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @gandhis1
assert_type()
to assert the type of any return valueAs mentioned in that issue, I am a little bit confused about what the type of a column or index label is.....feels like in some places we decided it is a
Hashable
and in other places we decided it's aScalar
. But just to stay consistent with the way this was already annotated, I continued to useScalar
.