Skip to content

fix: use Daft's native ddof for std/var, fix is_nan and null when predicates - #148

Merged
jonasdedden merged 2 commits into
narwhals-dev:mainfrom
jonasdedden:fix/std-var-ddof-nan-when
Nov 15, 2026
Merged

jonasdedden merged 2 commits into
narwhals-dev:mainfrom
jonasdedden:fix/std-var-ddof-nan-when

Conversation

@jonasdedden

Copy link
Copy Markdown
Member

Daft's stddev()/var() default to ddof=1 and accept ddof directly; they return null when there are no more than ddof valid values and work inside over, including row frames. std/var treated the default as the population statistic and rescaled it, so every ddof was off. Rolling std/var called F.stddev_samp/F.stddev_pop, which don't exist. All of them now pass ddof through, which also lifts the "only ddof 0/1" restriction on rolling_{std,var}.

Also:

  • is_nan used expr.float.is_nan(); there is no .float namespace any more, so it uses F.is_nan now. This fixes is_close too.
  • when/then/otherwise: Daft's when gives null instead of the otherwise value when the predicate is null, so the predicate is filled with False.

test_nan stays excluded: Daft's is_nan rejects integer input, while narwhals expects False.

Requires #147 (pin update) first. On top of that: 309 → 241 failures on the full suite, no new failures, and 16 names dropped from run_tests.py.

Note

I used Claude (Opus 5.5) to help with these changes and this description.

@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 90f398dd-8475-4943-8c25-23a80d237aa6
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@MarcoGorelli MarcoGorelli left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @jonasdedden !

@jonasdedden
jonasdedden force-pushed the fix/std-var-ddof-nan-when branch from ab2e67b to fb755a6 Compare November 15, 2026 14:12
@jonasdedden
jonasdedden merged commit a485ee8 into narwhals-dev:main Nov 15, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants