Skip to content

allow multiindex for a column in DataFrame.loc #494

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

Merged
merged 4 commits into from
Jan 3, 2023

Conversation

Dr-Irv
Copy link
Collaborator

@Dr-Irv Dr-Irv commented Jan 2, 2023

@Dr-Irv Dr-Irv requested a review from twoertwein January 2, 2023 22:18
@Dr-Irv Dr-Irv changed the title allow multiindex for a colu n in DataFrame.loc allow multiindex for a column in DataFrame.loc Jan 2, 2023
@@ -166,7 +166,9 @@ class _LocIndexerFrame(_LocIndexer):
@overload
def __getitem__(
self,
idx: tuple[int | StrLike | tuple[ScalarT, ...], int | StrLike],
idx: tuple[
int | StrLike | tuple[ScalarT, ...], int | StrLike | tuple[ScalarT, ...]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would Scalar also work here instead of ScalarT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would Scalar also work here instead of ScalarT?

Yes, seems so. Fixed in commit 3417725

@@ -15,7 +15,7 @@ from pandas._typing import (
)

_IndexSliceTuple: TypeAlias = tuple[
Union[Index, MaskType, Scalar, list[ScalarT], slice], ...
Union[Index, MaskType, Scalar, list[ScalarT], slice | tuple[ScalarT, ...]], ...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here (I think we need it for list but not sure about tuple).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here (I think we need it for list but not sure about tuple).

Yes, fixed in commit 3417725

index: Axes | None = ...,
dtype=...,
name: Hashable | None = ...,
copy: bool = ...,
fastpath: bool = ...,
) -> Series[IntervalT]: ...
) -> Series[Interval[int]]: ...
@overload
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice to add the TODO again

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue - included the changes from the other PR, so I've reverted that here in commit fb51203

@twoertwein twoertwein merged commit a349a49 into pandas-dev:main Jan 3, 2023
@twoertwein
Copy link
Member

Thanks @Dr-Irv !

@Dr-Irv Dr-Irv deleted the issue466 branch February 4, 2023 17:06
twoertwein pushed a commit to twoertwein/pandas-stubs that referenced this pull request Apr 1, 2023
* split Series[IntervalT] into separate __new__

* allow multiindex for a colun in DataFrame.loc

* revert changes related to Series.__new__ and IntervalT

* change tuple[ScalarT,...] to tuple[Scalar, ...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using pandas.DataFrame.loc with a tuple[str, str] multi-index seems to elicit mypy errors
2 participants