chore: remove kwargs from selector function#2058
Merged
MarcoGorelli merged 2 commits intonarwhals-dev:mainfrom Feb 20, 2025
Merged
chore: remove kwargs from selector function#2058MarcoGorelli merged 2 commits intonarwhals-dev:mainfrom
kwargs from selector function#2058MarcoGorelli merged 2 commits intonarwhals-dev:mainfrom
Conversation
| return [df[col] for col in df.columns] | ||
|
|
||
| return selector(self, func, lambda df: df.columns, {}) | ||
| return selector(self, func, lambda df: df.columns) |
Member
There was a problem hiding this comment.
I was planning to follow-up with replacing these lambdas:
diff --git a/narwhals/utils.py b/narwhals/utils.py
index cb33a603..05b9cc60 100644
--- a/narwhals/utils.py
+++ b/narwhals/utils.py
@@ -10,6 +10,7 @@ from secrets import token_hex
from typing import TYPE_CHECKING
from typing import Any
from typing import Iterable
+from typing import Iterator
from typing import Sequence
from typing import TypeVar
from typing import Union
@@ -59,6 +60,7 @@ if TYPE_CHECKING:
from narwhals.typing import DataFrameLike
from narwhals.typing import DTypes
from narwhals.typing import IntoSeriesT
+ from narwhals.typing import NativeFrame
from narwhals.typing import SizeUnit
from narwhals.typing import SupportsNativeNamespace
from narwhals.typing import TimeUnit
@@ -1303,6 +1305,14 @@ def dtype_matches_time_unit_and_time_zone(
)
+def get_columns(df: NativeFrame) -> Sequence[str]:
+ return df.columns
+
+
+def iter_columns(df: NativeFrame) -> Iterator[str]:
+ yield from df.columns
+
+
def _hasattr_static(obj: Any, attr: str) -> bool:
sentinel = object()
return getattr_static(obj, attr, sentinel) is not sentinel
iter_columns wouldn't be for this part, but would be usuable in lots of places
dangotbanned
approved these changes
Feb 20, 2025
Member
dangotbanned
left a comment
There was a problem hiding this comment.
Great stuff @MarcoGorelli
dangotbanned
added a commit
that referenced
this pull request
Feb 21, 2025
19 tasks
dangotbanned
pushed a commit
that referenced
this pull request
Feb 22, 2025
dangotbanned
added a commit
that referenced
this pull request
Feb 26, 2025
Mentioned in (#2058 (comment)) Originally in - (028098e) - c597ba7
10 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
follow-up to #2057 - there's a lot of
kwargswe're passing around that we don't needi'd generally like to refactor that whole mechanism (we'll need it for when we want to support
rolling_mean(n).over(group, order_by=id)), but for a start we can remove them when they're not neededWhat type of PR is this? (check all applicable)
Related issues
Checklist
If you have comments or can explain your changes, please do so below