-
Notifications
You must be signed in to change notification settings - Fork 170
refactor: Simplify PandasLikeNamespace.concat
#2368
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
Merged
+76
β162
Merged
Changes from 6 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0062258
refactor: `utils.horizontal_concat` -> `Namespace._horizontal_concat`
dangotbanned 5030b47
refactor: `utils.diagonal_concat` -> `Namespace._diagonal_concat`
dangotbanned 31952b9
refactor: `utils.vertical_concat` -> `Namespace._vertical_concat`
dangotbanned 69f374e
refactor: Even simpler!
dangotbanned b2c332f
refactor: Rename as `_concat_{ConcatMethod}`
dangotbanned 4abd0a5
typo
dangotbanned b6d0711
feat(typing): Get access to `pd.concat` docs, overloads
dangotbanned 1fa9f8f
refactor: Use property
dangotbanned fa30706
Merge branch 'main' into refac-pandas-concat
dangotbanned 657aef9
Merge branch 'main' into refac-pandas-concat
dangotbanned 0aee5bf
refactor(typing): Narrow `_concat_diagonal` to `Sequence[pd.DataFrame]`
dangotbanned 4ba461f
Merge branch 'main' into refac-pandas-concat
dangotbanned File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,16 @@ | ||
| from __future__ import annotations # pragma: no cover | ||
|
|
||
| from typing import TYPE_CHECKING # pragma: no cover | ||
| from typing import Union # pragma: no cover | ||
|
|
||
| if TYPE_CHECKING: | ||
| import sys | ||
| from typing import Any | ||
| from typing import TypeVar | ||
|
|
||
| if sys.version_info >= (3, 10): | ||
| from typing import TypeAlias | ||
| else: | ||
| from typing_extensions import TypeAlias | ||
| import pandas as pd | ||
| from typing_extensions import TypeAlias | ||
|
|
||
| from narwhals._pandas_like.expr import PandasLikeExpr | ||
| from narwhals._pandas_like.series import PandasLikeSeries | ||
|
|
||
| IntoPandasLikeExpr: TypeAlias = Union[PandasLikeExpr, PandasLikeSeries] | ||
| IntoPandasLikeExpr: TypeAlias = "PandasLikeExpr | PandasLikeSeries" | ||
| NDFrameT = TypeVar("NDFrameT", "pd.DataFrame", "pd.Series[Any]") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the output type always be
pd.DataFrameregardless of input indfs?Here a snippet:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well spotted!
So I added that type for
horizontal, which gets used with aSeriesas well (IIRC ingroup_bymaybe?).verticalused some property that is only available onDataFrame, so I had to make that one narrower.diagonal(I think) should work with either type, but is currently only used forDataFrame.Replying from my phone, hope that all makes sense π
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see what you mean now!
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#2368 (comment)
@FBruzzesi I think you'd also need to change the type of
dfsto be:If you kept theTypeVarinpyrightwill tell you off πEdit: I forgot about this new thing I learned π€¦ββοΈ #2283 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@FBruzzesi quite happy with this now (b6d0711)
Thanks for the
pandasπ§