-
Notifications
You must be signed in to change notification settings - Fork 179
chore: Spec CompliantLazyFrame
#2232
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
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
952f5aa
chore(typing): Mostly finish `CompliantLazyFrame`
dangotbanned af28859
fix: add missing `CompliantDataFrame.explode`
dangotbanned b15976e
feat(typing): Adds `not_implemented.deprecated`
dangotbanned 3b72e9d
chore(typing): Finish `PolarsLazyFrame`
dangotbanned 4441917
chore(typing): Finish `SparkLikeLazyFrame`
dangotbanned d34581b
chore(typing): Finish `DaskLazyFrame`
dangotbanned 8ec6aba
chore(typing): Finish `DuckDBLazyFrame`
dangotbanned 7e9e2bb
fix(typing): `PandasLikeDataFrame.explode`
dangotbanned 40625d4
chore(typing): Mark `.lazy` return as `Incomplete`
dangotbanned 169ddc7
Merge remote-tracking branch 'upstream/main' into compliant-lazyframeβ¦
dangotbanned 2f9d223
Merge remote-tracking branch 'upstream/main' into compliant-lazyframeβ¦
dangotbanned 4922bb9
Merge remote-tracking branch 'upstream/main' into compliant-lazyframeβ¦
dangotbanned df00903
chore(typing): Fill `Incomplete` for `*Expr`
dangotbanned 0757d3c
revert: remove `.to_(arrow|pandas)`
dangotbanned 3b81619
fix(DRAFT): Expose `CompliantLazyFrame.native`
dangotbanned e70cc47
fix: remove default in `CompliantLazyFrame.lazy`
dangotbanned 17ca5e8
fix(typing): Align `unique` sigantures
dangotbanned 62de258
fix: coverage for `PolarsLazyFrame.native`
dangotbanned ac25fde
fix(typing): Add missing `_change_version` method
dangotbanned 4100cb7
Merge branch 'main' into compliant-lazyframe-spec
dangotbanned 53c579e
chore(typing): Mark intended annotation, that isn't valid yet
dangotbanned 9a523ff
revert: remove `CompliantLazyFrame.lazy`
dangotbanned 3b6506b
Merge branch 'main' into compliant-lazyframe-spec
dangotbanned f906cce
lol `maintain_order` default one side only π
dangotbanned 22f4467
revert: don't widen `keep` for lazy
dangotbanned 8204537
Merge remote-tracking branch 'upstream/main' into compliant-lazyframeβ¦
dangotbanned 3f3e8a3
make `keep` a keyword again
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
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -16,7 +16,11 @@ | |||
| from narwhals._compliant.typing import CompliantSeriesT | ||||
| from narwhals._compliant.typing import EagerExprT_contra | ||||
| from narwhals._compliant.typing import EagerSeriesT | ||||
| from narwhals._compliant.typing import NativeFrameT_co | ||||
| from narwhals._expression_parsing import evaluate_output_names_and_aliases | ||||
| from narwhals.utils import Version | ||||
| from narwhals.utils import _StoresNative | ||||
| from narwhals.utils import deprecated | ||||
|
|
||||
| if TYPE_CHECKING: | ||||
| from io import BytesIO | ||||
|
|
@@ -70,6 +74,7 @@ def collect_schema(self) -> Mapping[str, DType]: ... | |||
| def drop(self, columns: Sequence[str], *, strict: bool) -> Self: ... | ||||
| def drop_nulls(self, subset: Sequence[str] | None) -> Self: ... | ||||
| def estimated_size(self, unit: SizeUnit) -> int | float: ... | ||||
| def explode(self: Self, columns: Sequence[str]) -> Self: ... | ||||
| def filter(self, predicate: CompliantExprT_contra | Incomplete) -> Self: ... | ||||
| def gather_every(self, n: int, offset: int) -> Self: ... | ||||
| def get_column(self, name: str) -> CompliantSeriesT: ... | ||||
|
|
@@ -101,7 +106,7 @@ def join_asof( | |||
| strategy: Literal["backward", "forward", "nearest"], | ||||
| suffix: str, | ||||
| ) -> Self: ... | ||||
| def lazy(self, *, backend: Implementation | None) -> CompliantLazyFrame: ... | ||||
| def lazy(self, *, backend: Implementation | None) -> CompliantLazyFrame[Any, Any]: ... | ||||
| def rename(self, mapping: Mapping[str, str]) -> Self: ... | ||||
| def row(self, index: int) -> tuple[Any, ...]: ... | ||||
| def rows( | ||||
|
|
@@ -136,7 +141,7 @@ def unique( | |||
| subset: Sequence[str] | None, | ||||
| *, | ||||
| keep: Literal["any", "first", "last", "none"], | ||||
| maintain_order: bool | None, | ||||
| maintain_order: bool | None = None, | ||||
| ) -> Self: ... | ||||
| def unpivot( | ||||
| self, | ||||
|
|
@@ -155,26 +160,101 @@ def write_csv(self, file: str | Path | BytesIO | None) -> str | None: ... | |||
| def write_parquet(self, file: str | Path | BytesIO) -> None: ... | ||||
|
|
||||
|
|
||||
| class CompliantLazyFrame(Protocol): | ||||
| class CompliantLazyFrame( | ||||
| _StoresNative[NativeFrameT_co], Protocol[CompliantExprT_contra, NativeFrameT_co] | ||||
| ): | ||||
dangotbanned marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
| _native_frame: Any | ||||
| _implementation: Implementation | ||||
| _backend_version: tuple[int, ...] | ||||
| _version: Version | ||||
|
|
||||
| def __narwhals_lazyframe__(self) -> Self: ... | ||||
| def __narwhals_namespace__(self) -> Any: ... | ||||
| def simple_select( | ||||
| self, *column_names: str | ||||
| ) -> Self: ... # `select` where all args are column names. | ||||
| def aggregate(self, *exprs: Any) -> Self: # pragma: no cover | ||||
| ... # `select` where all args are aggregations or literals | ||||
| # (so, no broadcasting is necessary). | ||||
|
|
||||
| def simple_select(self, *column_names: str) -> Self: | ||||
| """`select` where all args are column names.""" | ||||
| ... | ||||
|
|
||||
| def aggregate(self, *exprs: CompliantExprT_contra) -> Self: | ||||
| """`select` where all args are aggregations or literals. | ||||
|
|
||||
| (so, no broadcasting is necessary). | ||||
| """ | ||||
| ... | ||||
|
|
||||
| def _change_version(self, version: Version) -> Self: ... | ||||
dangotbanned marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
|
|
||||
| @property | ||||
| def native(self) -> NativeFrameT_co: | ||||
| return self._native_frame # type: ignore[no-any-return] | ||||
|
|
||||
| @property | ||||
| def columns(self) -> Sequence[str]: ... | ||||
| @property | ||||
| def schema(self) -> Mapping[str, DType]: ... | ||||
| def _iter_columns(self) -> Iterator[Any]: ... | ||||
| def collect( | ||||
| self, backend: Implementation | None, **kwargs: Any | ||||
| ) -> CompliantDataFrame[Any, Any]: ... | ||||
| def collect_schema(self) -> Mapping[str, DType]: ... | ||||
| def drop(self, columns: Sequence[str], *, strict: bool) -> Self: ... | ||||
| def drop_nulls(self, subset: Sequence[str] | None) -> Self: ... | ||||
| def explode(self: Self, columns: Sequence[str]) -> Self: ... | ||||
| def filter(self, predicate: CompliantExprT_contra | Incomplete) -> Self: ... | ||||
| @deprecated( | ||||
| "`LazyFrame.gather_every` is deprecated and will be removed in a future version." | ||||
| ) | ||||
| def gather_every(self, n: int, offset: int) -> Self: ... | ||||
| def group_by(self, *keys: str, drop_null_keys: bool) -> Incomplete: ... | ||||
| def head(self, n: int) -> Self: ... | ||||
| def join( | ||||
| self: Self, | ||||
| other: Self, | ||||
| *, | ||||
| how: Literal["left", "inner", "cross", "anti", "semi"], | ||||
| left_on: Sequence[str] | None, | ||||
| right_on: Sequence[str] | None, | ||||
| suffix: str, | ||||
| ) -> Self: ... | ||||
| def join_asof( | ||||
| self: Self, | ||||
| other: Self, | ||||
| *, | ||||
| left_on: str | None, | ||||
| right_on: str | None, | ||||
| by_left: Sequence[str] | None, | ||||
| by_right: Sequence[str] | None, | ||||
| strategy: Literal["backward", "forward", "nearest"], | ||||
| suffix: str, | ||||
| ) -> Self: ... | ||||
| def rename(self, mapping: Mapping[str, str]) -> Self: ... | ||||
| def select(self, *exprs: CompliantExprT_contra) -> Self: ... | ||||
| def sort( | ||||
| self, *by: str, descending: bool | Sequence[bool], nulls_last: bool | ||||
| ) -> Self: ... | ||||
| @deprecated("`LazyFrame.tail` is deprecated and will be removed in a future version.") | ||||
| def tail(self, n: int) -> Self: ... | ||||
| def unique( | ||||
| self, | ||||
| subset: Sequence[str] | None, | ||||
| *, | ||||
| keep: Literal["any", "none"], | ||||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was overkill The real problem to solve was narwhals/narwhals/_duckdb/dataframe.py Line 349 in a6361cd
|
||||
| ) -> Self: ... | ||||
| def unpivot( | ||||
| self, | ||||
| on: Sequence[str] | None, | ||||
| index: Sequence[str] | None, | ||||
| variable_name: str, | ||||
| value_name: str, | ||||
| ) -> Self: ... | ||||
| def with_columns(self, *exprs: CompliantExprT_contra) -> Self: ... | ||||
| def with_row_index(self, name: str) -> Self: ... | ||||
|
|
||||
|
|
||||
| class EagerDataFrame( | ||||
| CompliantDataFrame[EagerSeriesT, EagerExprT_contra], | ||||
| Protocol[EagerSeriesT, EagerExprT_contra], | ||||
| CompliantLazyFrame[EagerExprT_contra, NativeFrameT_co], | ||||
| Protocol[EagerSeriesT, EagerExprT_contra, NativeFrameT_co], | ||||
| ): | ||||
| def _evaluate_expr(self, expr: EagerExprT_contra, /) -> EagerSeriesT: | ||||
| """Evaluate `expr` and ensure it has a **single** output.""" | ||||
|
|
||||
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.