Skip to content
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

pandas reset_index() not allowing lists of index levels to remove #411

Closed
Dr-Irv opened this issue Sep 24, 2020 · 2 comments
Closed

pandas reset_index() not allowing lists of index levels to remove #411

Dr-Irv opened this issue Sep 24, 2020 · 2 comments
Assignees
Labels
fixed in next version (main) A fix has been implemented and will appear in an upcoming version typestub Issue relating to our bundled type stubs

Comments

@Dr-Irv
Copy link

Dr-Irv commented Sep 24, 2020

  • Language Server version: 2020.9.6
  • OS and version: Windows 10
  • Python version (& distribution if applicable, e.g. Anaconda): Anaconda Python 3.7.5

Expected behaviour

No error

Actual behaviour

import pandas as pd
df = pd.DataFrame.from_records([["a", "b", 3], ["a", "c", 4]], columns=["x", "y", "z"])
ndf: pd.DataFrame = df.set_index(["x", "y"])
ndf = ndf.reset_index(["x"])

s: pd.Series = ndf["z"]
sndf = s.reset_index(["x"])

reports errors:

No overloads for "ndf.reset_index(["x"])" match parameters
  Argument types: (List[str])

No overloads for "s.reset_index(["x"])" match parameters
  Argument types: (List[str])

Possible fix:

diff pandas/core/frame.pyi.ORIG pandas/core/frame.pyi
1230c1230
<         level: Level = ...,
---
>         level: Union[Level, List[Level]] = ...,
1240c1240
<         level: Level = ...,
---
>         level: Union[Level, List[Level]] = ...,
1250c1250
<         level: Level = ...,
---
>         level: Union[Level, List[Level]] = ...,
1259c1259
<         level: Level = ...,
---
>         level: Union[Level, List[Level]] = ...,

and

diff pandas/core/series.pyi.ORIG pandas/core/series.pyi
191c191
<         self, level: Optional[Level], drop: Literal[True], name: Optional[object] = ..., inplace: _bool = ...,
---
>         self, level: Optional[Union[Level,List[Level]]], drop: Literal[True], name: Optional[object] = ..., inplace: _bool = ...,
195c195
<         self, level: Optional[Level] = ..., name: Optional[object] = ..., inplace: _bool = ..., *, drop: Literal[True]
---
>         self, level: Optional[Union[Level,List[Level]]] = ..., name: Optional[object] = ..., inplace: _bool = ..., *, drop: Literal[True]
199c199
<         self, level: Optional[Level] = ..., drop: _bool = ..., name: Optional[object] = ..., inplace: _bool = ...,
---
>         self, level: Optional[Union[Level, List[Level]]] = ..., drop: _bool = ..., name: Optional[object] = ..., inplace: _bool = ...,
@jakebailey jakebailey added the typestub Issue relating to our bundled type stubs label Sep 24, 2020
@github-actions github-actions bot removed the triage label Sep 24, 2020
@gramster
Copy link
Member

Thanks again for these great bug reports!

@jakebailey jakebailey added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Sep 25, 2020
@jakebailey
Copy link
Member

This issue has been fixed in version 2020.9.7, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#202097-30-september-2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in next version (main) A fix has been implemented and will appear in an upcoming version typestub Issue relating to our bundled type stubs
Projects
None yet
Development

No branches or pull requests

3 participants