-
-
Notifications
You must be signed in to change notification settings - Fork 154
Closed
Description
Describe the bug
For the index argument, we should support iterables, but need to be careful that we don't allow plain strings.
index={"a":3, "c": 4}
s1 = pd.Series([1, 2], index=index)
s2 = pd.Series([1, 2], index=index.keys())
t = pd.Series([1,2], index="ab") # This should failCurrently, s1 and s2 are rejected by pyright, but should be accepted. t is rejected as well, but I'm including it because any change we make has to make sure this still fails.
To do this, we could modify the AxesData type in _typing.pyi to include Iterable[SeriesDType], but if we do that, then a plain str is accepted. To avoid that problem, I think adding a Series.__new__() overload with index: str returning Never right at the top (and similar for Index.__new__() with the data argument) would force that to be rejected.
The above tests should be included in a PR, where s1 and s2 are accepted, but t is not.
Metadata
Metadata
Assignees
Labels
No labels