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 read_csv() parse_dates parameter has incorrect type #576

Closed
Dr-Irv opened this issue Nov 6, 2020 · 1 comment
Closed

pandas read_csv() parse_dates parameter has incorrect type #576

Dr-Irv opened this issue Nov 6, 2020 · 1 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

Comments

@Dr-Irv
Copy link

Dr-Irv commented Nov 6, 2020

Environment data

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

Expected behaviour

No bug

Actual behaviour

df = pd.read_csv("foo.csv", parse_dates=["Start", "Finish"])

reports

No overloads for "pd.read_csv("foo.csv", parse_dates=["Start", "Finish"])" match parameters
  Argument types: (Literal['foo.csv'], List[str])

The issue here is that the parse_dates argument can be a number of things, including a list of column names.

Code Snippet / Additional information

Partial fix to pandas/io/parsers.pyi

 diff parsers.pyi.ORIG parsers.pyi
37c37
<     parse_dates: bool = ...,
---
>     parse_dates: Union[bool, List[int], List[str]] = ...,
374c374
<     parse_dates: bool = ...,
---
>     parse_dates: Union[bool, List[int], List[str]] = ...,
427c427
<     parse_dates: bool = ...,
---
>     parse_dates: Union[bool, List[int], List[str]] = ...,
764c764
<     parse_dates: bool = ...,
---
>     parse_dates: Union[bool, List[int], List[str]] = ...,

NOTE: This is not all the possible argument types for parse_dates, but the above solves this problem.

@github-actions github-actions bot added the triage label Nov 6, 2020
@jakebailey jakebailey added the typestub Issue relating to our bundled type stubs label Nov 6, 2020
@github-actions github-actions bot removed the triage label Nov 6, 2020
@jakebailey jakebailey added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Nov 11, 2020
@jakebailey
Copy link
Member

Thanks again for the patch.

This issue has been fixed in version 2020.11.1, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#2020111-11-november-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

2 participants