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

896 dataframe from dict columns dtype args #897

Merged

Conversation

mutricyl
Copy link
Contributor

tests/test_frame.py Outdated Show resolved Hide resolved
tests/test_frame.py Outdated Show resolved Hide resolved
pandas-stubs/core/frame.pyi Outdated Show resolved Hide resolved
@mutricyl
Copy link
Contributor Author

mutricyl commented Apr 1, 2024

I have added in f760452 new test and overload to cover when orient is not Literal

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Apr 1, 2024

I have added in f760452 new test and overload to cover when orient is not Literal

Let me know when I should do another review.

@mutricyl
Copy link
Contributor Author

mutricyl commented Apr 1, 2024

@Dr-Irv please proceed, tests on my computer just finished successfully

Comment on lines 292 to 298
@overload
@classmethod
def from_dict(
cls,
data: dict[Any, Any],
orient: Literal["columns", "index", "tight"] = ...,
dtype: _str = ...,
columns: list[_str] = ...,
orient: str,
dtype: AstypeArg | None = ...,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be removed. We only want to match the first or second overload. This would match any string for orient.

Comment on lines 1549 to 1550
# check when not using Literal
orient_str = "index"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the change I suggested above to remove the orient: str, the test below may fail. But that's OK - in this case the type checker isn't inferring that doing orient = "index" matches Literal["index"] . I'm pretty sure that pyright does that inference - not sure about mypy.

So if you make that change, and this test below fails, you can remove the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test does fail with mypy.

I'll revert my last commit to suppress the last overload and failing tests

Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @mutricyl

@Dr-Irv Dr-Irv merged commit 0342d90 into pandas-dev:main Apr 1, 2024
13 checks passed
@Dr-Irv Dr-Irv mentioned this pull request Apr 3, 2024
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 this pull request may close these issues.

pandas.DataFrame.from_dict : issue with dtype and columns arguments types
2 participants