Skip to content

docs(python): Clarify null handling in unique operations#27431

Merged
orlp merged 1 commit intopola-rs:mainfrom
uurl:docs/n-unique-null-values-7770
Apr 28, 2026
Merged

docs(python): Clarify null handling in unique operations#27431
orlp merged 1 commit intopola-rs:mainfrom
uurl:docs/n-unique-null-values-7770

Conversation

@uurl
Copy link
Copy Markdown
Contributor

@uurl uurl commented Apr 28, 2026

Closes #7770.

Summary

Clarifies that null is considered a unique value in Python API documentation for unique operations.

Updated docs for:

  • Series.unique
  • Series.n_unique
  • Expr.unique
  • pl.n_unique

Also updates the pl.n_unique and Series.n_unique examples to include None.

Validation

git diff --check
ruff check py-polars/src/polars/series/series.py py-polars/src/polars/expr/expr.py py-polars/src/polars/functions/lazy.py
python -m pytest \
  py-polars/tests/unit/operations/unique/test_n_unique.py \
  py-polars/tests/unit/operations/unique/test_unique.py \
  -k "n_unique or unique"
  • I used AI to help identify the narrow documentation scope and review the PR text.
  • I confirm that I have reviewed all changes myself, and I believe they are relevant and correct.
image

@github-actions github-actions Bot added documentation Improvements or additions to documentation python Related to Python Polars labels Apr 28, 2026
Comment thread py-polars/src/polars/functions/lazy.py Outdated
>>> df = pl.DataFrame(
... {
... "a": [1, 8, 1],
... "a": [1, 8, None],
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.

This example now is missing a duplicate value. Can you make it 1, 1, None?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, updated the example to keep a duplicate value while including None. Thanks

@uurl uurl force-pushed the docs/n-unique-null-values-7770 branch from 0087580 to 2ae7877 Compare April 28, 2026 14:02
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.55%. Comparing base (693c520) to head (2ae7877).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #27431      +/-   ##
==========================================
- Coverage   81.19%   79.55%   -1.64%     
==========================================
  Files        1832     1836       +4     
  Lines      253247   254204     +957     
  Branches     3176     3177       +1     
==========================================
- Hits       205626   202237    -3389     
- Misses      46798    51143    +4345     
- Partials      823      824       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@orlp orlp merged commit 577933b into pola-rs:main Apr 28, 2026
26 checks passed
@uurl uurl deleted the docs/n-unique-null-values-7770 branch April 29, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation python Related to Python Polars

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DOC] n_unique considers null values

2 participants