Skip to content

read_sql_* methods should accept dtype argument with same type as DataFrame.astype() #676

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

Closed
Dr-Irv opened this issue May 2, 2023 · 4 comments · Fixed by #680
Closed

Comments

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented May 2, 2023

For the read_sql_* methods, the argument dtype is just passed to DataFrame.astype(), where we allow dtype: AstypeArg | Mapping[Any, Dtype] | Series, so the read_sql_*() methods should do the same.

In particular, doing something like dtype: {"col": "str"} is totally allowed, but not permitted in the stubs.

pandas-stubs version 2.0.1.230501

@Dr-Irv
Copy link
Collaborator Author

Dr-Irv commented May 2, 2023

@ramvikrams can you fix this? You added the argument before, so maybe you can do this?

@ramvikrams
Copy link
Contributor

Thank you @Dr-Irv I will surely do it

@Dr-Irv
Copy link
Collaborator Author

Dr-Irv commented May 3, 2023

The solution here is actually simpler than I thought. Try changing

DtypeArg: TypeAlias = Dtype | dict[Any, Dtype]
to use Mapping instead of dict, and then just add a test that has a string in the value of the dict.

@ramvikrams
Copy link
Contributor

ramvikrams commented May 3, 2023

The solution here is actually simpler than I thought. Try changing

DtypeArg: TypeAlias = Dtype | dict[Any, Dtype]

to use Mapping instead of dict, and then just add a test that has a string in the value of the dict.

i'll do it via this way then

Dr-Irv added a commit that referenced this issue May 6, 2023
* GH-676

* Update test_io.py

* Update tests/test_io.py

Co-authored-by: Irv Lustig <[email protected]>

* Update test_io.py

---------

Co-authored-by: Irv Lustig <[email protected]>
Dr-Irv added a commit that referenced this issue May 18, 2023
…l` (#695)

* GH-676

* Update test_io.py

* Update tests/test_io.py

Co-authored-by: Irv Lustig <[email protected]>

* Update test_io.py

* added `date_format` to `read_table`,`read_fwf` and `read_excel`

* req changes

* Update test_io.py

* Update test_io.py

* made `date_format` consistent and changed the tests

---------

Co-authored-by: Irv Lustig <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants