-
Notifications
You must be signed in to change notification settings - Fork 175
feat: Add support for {DataFrame,LazyFrame,Series}.clear method
#2896
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
Open
FBruzzesi
wants to merge
15
commits into
main
Choose a base branch
from
feat/dataframe-clear
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+393
β1
Open
Changes from 2 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9b860be
feat: Add support for DataFrame.clear
FBruzzesi 19398fa
merge main
FBruzzesi 7977f22
merge main
FBruzzesi 792c0e8
getting there for lazy
FBruzzesi d2c69c2
variable renaming and typing
FBruzzesi c3ecc0e
pyspark native
FBruzzesi 74f8ab0
keep it simple for now
FBruzzesi cf94d12
docstrings
FBruzzesi 3006fec
let's be more flexible for pandas
FBruzzesi ec65310
skip for pandas version before min nullable
FBruzzesi 0eaf36b
here is you reason pytest
FBruzzesi 271718a
be stricter than polars on input type
FBruzzesi 40a7902
in for a penny in for a pound, Series.clear
FBruzzesi 7c2cbe8
match polars exception msg
FBruzzesi c230db2
merge main
FBruzzesi 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| members: | ||
| - __arrow_c_stream__ | ||
| - __getitem__ | ||
| - clear | ||
| - clone | ||
| - collect_schema | ||
| - columns | ||
|
|
||
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
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 |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import pytest | ||
|
|
||
| import narwhals as nw | ||
| from tests.utils import ConstructorEager, assert_equal_data | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("n", [0, 1, 10]) | ||
| def test_clear(constructor_eager: ConstructorEager, n: int) -> None: | ||
| data = { | ||
| "int": [1, 2, 3], | ||
| "str": ["foo", "bar", "baz"], | ||
| "float": [0.1, 0.2, 0.3], | ||
| "bool": [True, False, True], | ||
| } | ||
| df = nw.from_native(constructor_eager(data), eager_only=True) | ||
| df_clear = df.clear(n=n) | ||
|
|
||
| assert len(df_clear) == n | ||
| assert df.schema == df_clear.schema | ||
|
|
||
| assert_equal_data(df_clear, {k: [None] * n for k in data}) | ||
|
|
||
|
|
||
| def test_clear_negative(constructor_eager: ConstructorEager) -> None: | ||
| n = -1 | ||
| data = {"a": [1, 2, 3]} | ||
| df = nw.from_native(constructor_eager(data), eager_only=True) | ||
|
|
||
| msg = f"`n` should be greater than or equal to 0, got {n}" | ||
| with pytest.raises(ValueError, match=msg): | ||
| df.clear(n=n) |
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.