-
Notifications
You must be signed in to change notification settings - Fork 121
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
feat: add support for Series|Expr.skew
method
#1173
Merged
Merged
Changes from 17 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
90d9742
Implement skew for Arrow, Pandas-like and Polars
CarloLepelaars c82fec1
Fix doctests
CarloLepelaars e118e4d
Remove skew in namespace. Remove n > 3 requirement. Fix expr doc
CarloLepelaars 2530f81
Use biases population skewness
CarloLepelaars fc37529
Add pyarrow example for skew Expr
CarloLepelaars be2f503
Merge branch 'main' into feat/skew
CarloLepelaars 02fdb4c
Fix: Add a_skew to schema
CarloLepelaars 895be9c
Use native operation for PandasLikeSeries skew. Dask skew expr
CarloLepelaars a3b71bc
Use native pyarrow operations for skew
CarloLepelaars 9ed06d7
Merge branch 'main' into feat/skew
CarloLepelaars 4ff077d
Simplify arrow skew. non-trivial example for series.skew.
CarloLepelaars 11efd49
unary_test with nan data. 2 element and 1 element unary tests
CarloLepelaars 26a64f8
Fix doctest for Series skew
CarloLepelaars 2014036
Make skew nan policy consistent with Polars
CarloLepelaars aaada24
Merge branch 'main' into feat/skew
FBruzzesi 3e7eeab
merge main
FBruzzesi 7f6fe07
merge main and add test for coverage
FBruzzesi 2f2912c
Merge branch 'main' into feat/skew
FBruzzesi 082664f
match RuntimeWarning for dask only
FBruzzesi 56299a3
Merge remote-tracking branch 'upstream/main' into feat/skew
MarcoGorelli 2dac3f3
stay pyarrow-native longer
MarcoGorelli 0d3b6ec
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 7f91b19
fix mistake
MarcoGorelli 3399530
Merge branch 'feat/skew' of github.com:CarloLepelaars/narwhals into f…
MarcoGorelli 87f71d7
doctest
MarcoGorelli 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 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 |
---|---|---|
|
@@ -43,6 +43,7 @@ | |
- sample | ||
- shift | ||
- sort | ||
- skew | ||
- std | ||
- sum | ||
- tail | ||
|
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 |
---|---|---|
|
@@ -52,6 +52,7 @@ | |
- shape | ||
- shift | ||
- sort | ||
- skew | ||
- std | ||
- sum | ||
- tail | ||
|
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,29 @@ | ||
from __future__ import annotations | ||
|
||
import pytest | ||
|
||
import narwhals.stable.v1 as nw | ||
from tests.utils import ConstructorEager | ||
from tests.utils import assert_equal_data | ||
|
||
data = [1, 2, 3, 2, 1] | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("size", "expected"), | ||
[ | ||
(0, None), | ||
(1, float("nan")), | ||
(2, 0.0), | ||
(5, 0.343622), | ||
], | ||
) | ||
def test_skew_series( | ||
constructor_eager: ConstructorEager, size: int, expected: float | None | ||
) -> None: | ||
result = ( | ||
nw.from_native(constructor_eager({"a": data}), eager_only=True) | ||
.head(size)["a"] | ||
.skew() | ||
) | ||
assert_equal_data({"a": [result]}, {"a": [expected]}) |
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.
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.
In case of dask, the behavior is not 100% consistent with polars for length 0, 1, 2.
Honestly, I am ok with that. The majority of use cases, especially if distributed data is needed should not involve those sizes to begin with