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

Internal read_excel() typing for index_col is incorrect #55843

Closed
Dr-Irv opened this issue Nov 6, 2023 · 5 comments · Fixed by #55857
Closed

Internal read_excel() typing for index_col is incorrect #55843

Dr-Irv opened this issue Nov 6, 2023 · 5 comments · Fixed by #55857
Assignees
Labels
good first issue IO Excel read_excel, to_excel Typing type annotations, mypy/pyright type checking
Milestone

Comments

@Dr-Irv
Copy link
Contributor

Dr-Irv commented Nov 6, 2023

Inside the pandas source, the index_col argument for read_excel() is typed as:

    index_col: int | Sequence[int] | None = ...,

But the docs say that a string is accepted, as shown in the example below.

from pandas import read_excel
print(read_excel("Book1.xlsx"))
print(read_excel("Book1.xlsx", index_col="bar"))

Output:

   foo  bar
0    1    2
1    3    4
     foo
bar     
2      1
4      3

Book1.xlsx

Originally posted by @clo-vis in pandas-dev/pandas-stubs#809 (comment)

@lithomas1 lithomas1 added good first issue Typing type annotations, mypy/pyright type checking labels Nov 6, 2023
@himanshu238
Copy link

Hello, Himanshu here. I want try and resolve this issue but as I am new to opens source and to this project so I will start by going through the contributing guidelines but I will require a little assistance because this will be my first issue. Please assist me if possible @Dr-Irv and @lithomas1. Thank you

@Dr-Irv
Copy link
Contributor Author

Dr-Irv commented Nov 6, 2023

Hello, Himanshu here. I want try and resolve this issue but as I am new to opens source and to this project so I will start by going through the contributing guidelines but I will require a little assistance because this will be my first issue. Please assist me if possible @Dr-Irv and @lithomas1. Thank you

Follow the guidelines to get set up. If you need help, best to ask on the slack channel. See https://pandas.pydata.org/docs/development/community.html#community-slack

The right thing to do here is to just make changes with typing declarations for read_excel() and downstream functions/methods that use the index_col argument. You need to add str as an accepted argument type in those places.

@himanshu238
Copy link

Thank you for your response @Dr-Irv. I have joined the slack channel and I will start working on this issue. If there is any doubt I will reach out to you and other fellow contributors on slack.

@Dr-Irv
Copy link
Contributor Author

Dr-Irv commented Nov 7, 2023

@himanshu238 it appears someone else picked this up and did the fix. Hope you didn't spend too much time working on it.

@himanshu238
Copy link

Okay @Dr-Irv I will look for other issues and try to fix them. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue IO Excel read_excel, to_excel Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants