Skip to content

Commit 6a4522c

Browse files
committed
fixed bugs
1 parent f64b0e6 commit 6a4522c

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

doc/source/comparison_with_sql.rst

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -400,17 +400,10 @@ Top N rows per group
400400
ROW_NUMBER() OVER(PARTITION BY day ORDER BY total_bill DESC) AS rn
401401
FROM tips t
402402
)
403-
WHERE rn <= 3
403+
WHERE rn < 3
404404
ORDER BY day, rn;
405405
406-
.. ipython:: python
407-
408-
(tips.sort_values(['total_bill'], ascending=False)
409-
.groupby('sex')
410-
.head(3)
411-
)
412-
413-
Let's add an `RN` (Row Number) column
406+
Let's add a helper column: `RN` (Row Number)
414407

415408
.. ipython:: python
416409
@@ -425,7 +418,7 @@ the same using `rank(method='first')` function
425418
.. ipython:: python
426419
427420
tips['rnk'] = (tips.groupby(['day'])['total_bill']
428-
.rank(method='first', ascending=False
421+
.rank(method='first', ascending=False)
429422
)
430423
tips.loc[tips['rnk'] < 3].sort_values(['day','rnk'])
431424

0 commit comments

Comments
 (0)