Closed
Description
Describe the bug
Using
df = pd.DataFrame({"a": [1, 2, 3], "b": 1})
x: pd.DataFrame = df.groupby("a", as_index=False).value_counts()
raises an error, because mypy thinks the return is a Series
Incompatible types in assignment (expression has type "Series[int]", variable has type "DataFrame") [assignment]
To Reproduce
- Provide a minimal runnable
pandas
example that is not properly checked by the stubs. - Indicate which type checker you are using (
mypy
orpyright
). - Show the error message received from that type checker while checking your example.
df = pd.DataFrame({"a": [1, 2, 3], "b": 1})
x: pd.DataFrame = df.groupby("a", as_index=False).value_counts()
In theory this should be ok, but not sure if this as_index=False
can be typed?
Please complete the following information:
- OS: ubuntu
- OS Version 22.04
- python version 3.10
- version of type checker mypy 0.971
- version of installed
pandas-stubs
newest 20220815
Additional context
Add any other context about the problem here.