-
-
Notifications
You must be signed in to change notification settings - Fork 145
type multiindex constructors #1126
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
from collections.abc import ( | ||
Callable, | ||
Hashable, | ||
Iterable, | ||
Sequence, | ||
) | ||
from typing import ( | ||
|
@@ -16,6 +17,7 @@ from pandas.core.indexes.base import Index | |
from typing_extensions import Self | ||
|
||
from pandas._typing import ( | ||
AnyArrayLike, | ||
Dtype, | ||
DtypeArg, | ||
HashableT, | ||
|
@@ -27,31 +29,42 @@ from pandas._typing import ( | |
class MultiIndex(Index[Any]): | ||
def __new__( | ||
cls, | ||
levels=..., | ||
codes=..., | ||
sortorder=..., | ||
levels: SequenceNotStr[SequenceNotStr[Hashable] | AnyArrayLike] = ..., | ||
codes: SequenceNotStr[SequenceNotStr[int]] = ..., | ||
MarcoGorelli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
sortorder: int | None = ..., | ||
names: SequenceNotStr[Hashable] = ..., | ||
dtype=..., | ||
MarcoGorelli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
copy=..., | ||
copy: bool = ..., | ||
name: SequenceNotStr[Hashable] = ..., | ||
verify_integrity: bool = ..., | ||
_set_identity: bool = ..., | ||
MarcoGorelli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) -> Self: ... | ||
@classmethod | ||
def from_arrays( | ||
cls, arrays, sortorder=..., names: SequenceNotStr[Hashable] = ... | ||
cls, | ||
arrays: SequenceNotStr[SequenceNotStr[Hashable] | AnyArrayLike], | ||
sortorder: int | None = ..., | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one's a bit odd The name is But, the pandas docs (and tests) have several examples of passing lists, which are not
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤔 maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it should be >>> pd.MultiIndex.from_arrays([range(2), [3,4]], names=["a", "b"])
MultiIndex([(0, 3),
(1, 4)],
names=['a', 'b'])
>>> pd.MultiIndex.from_arrays([{1:"x", 2:"y"}, [3,4]], names=["a", "b"])
MultiIndex([(1, 3),
(2, 4)],
names=['a', 'b']) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Problem is that |
||
names: SequenceNotStr[Hashable] = ..., | ||
) -> Self: ... | ||
@classmethod | ||
def from_tuples( | ||
cls, tuples, sortorder=..., names: SequenceNotStr[Hashable] = ... | ||
cls, | ||
tuples: Iterable[tuple[Hashable, ...]], | ||
MarcoGorelli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
sortorder: int | None = ..., | ||
names: SequenceNotStr[Hashable] = ..., | ||
) -> Self: ... | ||
@classmethod | ||
def from_product( | ||
cls, iterables, sortorder=..., names: SequenceNotStr[Hashable] = ... | ||
cls, | ||
iterables: SequenceNotStr[Iterable[Hashable]], | ||
MarcoGorelli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
sortorder: int | None = ..., | ||
names: SequenceNotStr[Hashable] = ..., | ||
) -> Self: ... | ||
@classmethod | ||
def from_frame( | ||
cls, df, sortorder=..., names: SequenceNotStr[Hashable] = ... | ||
cls, | ||
df: pd.DataFrame, | ||
sortorder: int | None = ..., | ||
names: SequenceNotStr[Hashable] = ..., | ||
) -> Self: ... | ||
@property | ||
def shape(self): ... | ||
|
Uh oh!
There was an error while loading. Please reload this page.