Closed
Description
Describe the bug
The stubs for pandas_stubs.core.strings.StringMethods.split
do not return pandas.Series[list[str]]
type with expand=False
parameter for Series/Index containing lists of strings as described in docs.
To Reproduce
Use VS Code with Pylance extension:
- The following:
cause Pylance error below:
from pandas import Series s = Series(["one", "two"]) def split(s: "Series[str]") -> "Series[list[str]]": # error return s.str.split(expand=False) split(s)
Type "list[str]" cannot be assigned to type variable "S1@Series" Type "list[str]" is not assignable to upper bound "Dtype | bytes | date | time | bool | int | float | complex | datetime | timedelta | Period | Interval[Unknown] | CategoricalDtype | BaseOffset" for type variable "S1@Series" Type "list[str]" is not assignable to type "Dtype | bytes | date | time | bool | int | float | complex | datetime | timedelta | Period | Interval[Unknown] | CategoricalDtype | BaseOffset" "list[str]" is not assignable to "str" "list[str]" is not assignable to "bytes" "list[str]" is not assignable to "date" "list[str]" is not assignable to "time" "list[str]" is not assignable to "bool" "list[str]" is not assignable to "int" ...PylancereportInvalidTypeArguments
- The following is type of "Series[Unknown]":
from pandas import Series s = Series(["one", "two"]) s = s.str.split(expand=False) reveal_type(s) # Type of "s" is "Series[Unknown]"
Please complete the following information:
- OS : MacOS
- OS Version : Sonoma 14.7.1
- python : 3.10.14
- processor : arm64
- VS Code : 1.96.0 (Universal)
- pandas : 2.2.3
- pandas-stubs : 2.2.3.241126
- Pylance : 2024.12.1
Metadata
Metadata
Assignees
Labels
No labels