Skip to content

Commit 73d63a4

Browse files
timsaucerclaude
andcommitted
Align module-docstring examples with SKILL.md idioms
Drop the redundant lit() in the dataframe.py module-docstring filter example and use a plain string group key in the aggregate() doctest, so both examples model the style SKILL.md recommends. Also document the sort("a") string form and sort_by() shortcut in SKILL.md's sorting section. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5ab511d commit 73d63a4

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

SKILL.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,22 @@ aggregate.
128128
### Sorting
129129

130130
```python
131-
df.sort(col("a")) # ascending (default)
131+
df.sort("a") # ascending (plain name, preferred)
132+
df.sort(col("a")) # ascending via col()
132133
df.sort(col("a").sort(ascending=False)) # descending
133134
df.sort(col("a").sort(nulls_first=False)) # override null placement
135+
136+
df.sort_by("a", "b") # ascending-only shortcut
134137
```
135138

136-
A plain expression passed to `sort()` is already treated as ascending. Only
137-
reach for `col(...).sort(...)` when you need to override a default (descending
138-
order or null placement). Writing `col("a").sort(ascending=True)` is redundant.
139+
As with `select()` and `aggregate()`, bare column references can be passed as
140+
plain name strings. A plain expression passed to `sort()` is already treated
141+
as ascending, so reach for `col(...).sort(...)` only when you need to override
142+
a default (descending order or null placement). Writing
143+
`col("a").sort(ascending=True)` is redundant.
144+
145+
For ascending-only sorts with no null-placement override, `df.sort_by(...)` is
146+
a shorter alias for `df.sort(...)`.
139147

140148
### Joining
141149

python/datafusion/dataframe.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
Examples:
3636
>>> ctx = dfn.SessionContext()
3737
>>> df = ctx.from_pydict({"a": [1, 2, 3], "b": [10, 20, 30]})
38-
>>> df.filter(col("a") > lit(1)).select("b").to_pydict()
38+
>>> df.filter(col("a") > 1).select("b").to_pydict()
3939
{'b': [20, 30]}
4040
4141
See :ref:`user_guide_concepts` in the online documentation for a high-level
@@ -812,7 +812,7 @@ def aggregate(
812812
Group by a column and produce one row per group:
813813
814814
>>> df.aggregate(
815-
... [col("team")], [F.sum(col("score")).alias("total")]
815+
... ["team"], [F.sum(col("score")).alias("total")]
816816
... ).sort("team").to_pydict()
817817
{'team': ['x', 'y'], 'total': [3, 5]}
818818
"""

0 commit comments

Comments
 (0)