Uh oh!
There was an error while loading. Please reload this page.
Add docstring examples for Aggregate statistical and regression functions - #1417
Conversation
…ions Add example usage to docstrings for Aggregate statistical and regression functions to improve documentation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
kosiew
left a comment
There was a problem hiding this comment.
@ntjohnson1
Thank you for your contribution.
| >>> builtins.round( | ||
| ... result.collect_column("v")[0].as_py(), 4 |
There was a problem hiding this comment.
This example can be simplified by choosing input values with an exact covariance result instead of importing builtins just to round the output.
That would make covar_pop read more like the surrounding examples.
| --------- | ||
| >>> ctx = dfn.SessionContext() | ||
| >>> df = ctx.from_pydict({"a": [1.0, 2.0, 3.0], "b": [4.0, 5.0, 6.0]}) | ||
| >>> result = df.aggregate( | ||
| ... [], [dfn.functions.covar(dfn.col("a"), dfn.col("b")).alias("v")]) | ||
| >>> result.collect_column("v")[0].as_py() | ||
| 1.0 |
There was a problem hiding this comment.
Since covar() is an alias of covar_samp(), and the new example is a verbatim duplicate of the covar_samp function’s example, do you think keeping the example only on covar_samp() and leaving the alias docstring short would avoid doc drift?
kosiew
commented
Mar 17, 2026
@ntjohnson1 |
…docstrings-agg-stat
Uh oh!
There was an error while loading. Please reload this page.
Which issue does this PR close?
Rationale for this change
Add example usage to docstrings for Aggregate statistical and regression functions to improve documentation.
What changes are included in this PR?
The first PR was basically adding a docstring to everything in functions. I broke it apart into a PR (that already merged) for the infra. I then reviewed and merged an example PR of adding the docstrings in parts. This is now the follow up opening a handful of PRs for the remaining functions in functions.py Everything is co-authored with Claude since I used claude to extend the handwritten examples I wrote for reference and to split apart the large PR rather than doing it manually.
I've reviewed all the code prior to PR.
Are there any user-facing changes?
No