Skip to content

Commit

Permalink
fix: adjust duckdb population skewness by correction factor to get sa…
Browse files Browse the repository at this point in the history
…mple skewness (#2021)
  • Loading branch information
FBruzzesi authored Feb 16, 2025
1 parent 6d07f89 commit 3aefc49
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 3 additions & 0 deletions narwhals/_duckdb/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,10 @@ def func(_input: duckdb.Expression) -> duckdb.Expression:
condition=(count == lit(1)), value=lit(float("nan"))
).otherwise(
CaseExpression(condition=(count == lit(2)), value=lit(0.0)).otherwise(
# Adjust population skewness by correction factor to get sample skewness
FunctionExpression("skewness", _input)
* (count - lit(2))
/ FunctionExpression("sqrt", count * (count - lit(1)))
)
)
)
Expand Down
4 changes: 1 addition & 3 deletions tests/expr_and_series/unary_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
from tests.utils import assert_equal_data


def test_unary(constructor: Constructor, request: pytest.FixtureRequest) -> None:
if "duckdb" in str(constructor):
request.applymarker(pytest.mark.xfail)
def test_unary(constructor: Constructor) -> None:
data = {
"a": [1, 3, 2],
"b": [4, 4, 6],
Expand Down

0 comments on commit 3aefc49

Please sign in to comment.