-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
239 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
- drop | ||
- drop_nulls | ||
- filter | ||
- gather_every | ||
- get_column | ||
- group_by | ||
- head | ||
|
This file contains 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,6 +16,7 @@ | |
- drop_nulls | ||
- fill_null | ||
- filter | ||
- gather_every | ||
- head | ||
- is_between | ||
- is_duplicated | ||
|
This file contains 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 |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
- drop | ||
- drop_nulls | ||
- filter | ||
- gather_every | ||
- group_by | ||
- head | ||
- join | ||
|
This file contains 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 |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
- dtype | ||
- fill_null | ||
- filter | ||
- gather_every | ||
- head | ||
- is_between | ||
- is_duplicated | ||
|
This file contains 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 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 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 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 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 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 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 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 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 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,30 @@ | ||
from typing import Any | ||
|
||
import pytest | ||
|
||
import narwhals.stable.v1 as nw | ||
from tests.utils import compare_dicts | ||
|
||
data = {"a": list(range(10))} | ||
|
||
|
||
@pytest.mark.parametrize("n", [1, 2, 3]) | ||
@pytest.mark.parametrize("offset", [1, 2, 3]) | ||
def test_gather_every_expr(constructor_with_lazy: Any, n: int, offset: int) -> None: | ||
df = nw.from_native(constructor_with_lazy(data)) | ||
|
||
result = df.select(nw.col("a").gather_every(n=n, offset=offset)) | ||
expected = {"a": data["a"][offset::n]} | ||
|
||
compare_dicts(result, expected) | ||
|
||
|
||
@pytest.mark.parametrize("n", [1, 2, 3]) | ||
@pytest.mark.parametrize("offset", [1, 2, 3]) | ||
def test_gather_every_series(constructor_series: Any, n: int, offset: int) -> None: | ||
series = nw.from_native(constructor_series(data["a"]), series_only=True) | ||
|
||
result = series.gather_every(n=n, offset=offset) | ||
expected = data["a"][offset::n] | ||
|
||
assert result.to_list() == expected |
This file contains 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,17 @@ | ||
from typing import Any | ||
|
||
import pytest | ||
|
||
import narwhals.stable.v1 as nw | ||
from tests.utils import compare_dicts | ||
|
||
data = {"a": list(range(10))} | ||
|
||
|
||
@pytest.mark.parametrize("n", [1, 2, 3]) | ||
@pytest.mark.parametrize("offset", [1, 2, 3]) | ||
def test_gather_every(constructor_with_lazy: Any, n: int, offset: int) -> None: | ||
df = nw.from_native(constructor_with_lazy(data)) | ||
result = df.gather_every(n=n, offset=offset) | ||
expected = {"a": data["a"][offset::n]} | ||
compare_dicts(result, expected) |