259
259
"dense_rank" ,
260
260
"percent_rank" ,
261
261
"cume_dist" ,
262
+ "ntile" ,
262
263
]
263
264
264
265
@@ -1816,18 +1817,16 @@ def rank() -> Expr:
1816
1817
is an example of a dataframe with a window ordered by descending ``points`` and the
1817
1818
associated rank.
1818
1819
1819
- You should set ``order_by`` to produce meaningful results.
1820
+ You should set ``order_by`` to produce meaningful results::
1820
1821
1821
- ```
1822
- +--------+------+
1823
- | points | rank |
1824
- +--------+------+
1825
- | 100 | 1 |
1826
- | 100 | 1 |
1827
- | 50 | 3 |
1828
- | 25 | 4 |
1829
- +--------+------+
1830
- ```
1822
+ +--------+------+
1823
+ | points | rank |
1824
+ +--------+------+
1825
+ | 100 | 1 |
1826
+ | 100 | 1 |
1827
+ | 50 | 3 |
1828
+ | 25 | 4 |
1829
+ +--------+------+
1831
1830
1832
1831
To set window function parameters use the window builder approach described in the
1833
1832
ref:`_window_functions` online documentation.
@@ -1840,18 +1839,16 @@ def dense_rank() -> Expr:
1840
1839
1841
1840
This window function is similar to :py:func:`rank` except that the returned values
1842
1841
will be consecutive. Here is an example of a dataframe with a window ordered by
1843
- descending ``points`` and the associated dense rank.
1842
+ descending ``points`` and the associated dense rank::
1844
1843
1845
- ```
1846
- +--------+------------+
1847
- | points | dense_rank |
1848
- +--------+------------+
1849
- | 100 | 1 |
1850
- | 100 | 1 |
1851
- | 50 | 2 |
1852
- | 25 | 3 |
1853
- +--------+------------+
1854
- ```
1844
+ +--------+------------+
1845
+ | points | dense_rank |
1846
+ +--------+------------+
1847
+ | 100 | 1 |
1848
+ | 100 | 1 |
1849
+ | 50 | 2 |
1850
+ | 25 | 3 |
1851
+ +--------+------------+
1855
1852
1856
1853
To set window function parameters use the window builder approach described in the
1857
1854
ref:`_window_functions` online documentation.
@@ -1865,18 +1862,16 @@ def percent_rank() -> Expr:
1865
1862
This window function is similar to :py:func:`rank` except that the returned values
1866
1863
are the percentage from 0.0 to 1.0 from first to last. Here is an example of a
1867
1864
dataframe with a window ordered by descending ``points`` and the associated percent
1868
- rank.
1865
+ rank::
1869
1866
1870
- ```
1871
- +--------+--------------+
1872
- | points | percent_rank |
1873
- +--------+--------------+
1874
- | 100 | 0.0 |
1875
- | 100 | 0.0 |
1876
- | 50 | 0.666667 |
1877
- | 25 | 1.0 |
1878
- +--------+--------------+
1879
- ```
1867
+ +--------+--------------+
1868
+ | points | percent_rank |
1869
+ +--------+--------------+
1870
+ | 100 | 0.0 |
1871
+ | 100 | 0.0 |
1872
+ | 50 | 0.666667 |
1873
+ | 25 | 1.0 |
1874
+ +--------+--------------+
1880
1875
1881
1876
To set window function parameters use the window builder approach described in the
1882
1877
ref:`_window_functions` online documentation.
@@ -1890,18 +1885,16 @@ def cume_dist() -> Expr:
1890
1885
This window function is similar to :py:func:`rank` except that the returned values
1891
1886
are the ratio of the row number to the total numebr of rows. Here is an example of a
1892
1887
dataframe with a window ordered by descending ``points`` and the associated
1893
- cumulative distribution.
1888
+ cumulative distribution::
1894
1889
1895
- ```
1896
- +--------+-----------+
1897
- | points | cume_dist |
1898
- +--------+-----------+
1899
- | 100 | 0.5 |
1900
- | 100 | 0.5 |
1901
- | 50 | 0.75 |
1902
- | 25 | 1.0 |
1903
- +--------+-----------+
1904
- ```
1890
+ +--------+-----------+
1891
+ | points | cume_dist |
1892
+ +--------+-----------+
1893
+ | 100 | 0.5 |
1894
+ | 100 | 0.5 |
1895
+ | 50 | 0.75 |
1896
+ | 25 | 1.0 |
1897
+ +--------+-----------+
1905
1898
1906
1899
To set window function parameters use the window builder approach described in the
1907
1900
ref:`_window_functions` online documentation.
@@ -1915,23 +1908,20 @@ def ntile(groups: int) -> Expr:
1915
1908
This window function orders the window frame into a give number of groups based on
1916
1909
the ordering criteria. It then returns which group the current row is assigned to.
1917
1910
Here is an example of a dataframe with a window ordered by descending ``points``
1918
- and the associated n-tile function.
1919
-
1920
- ```
1921
- +--------+-------+
1922
- | points | ntile |
1923
- +--------+-------+
1924
- | 120 | 1 |
1925
- | 100 | 1 |
1926
- | 80 | 2 |
1927
- | 60 | 2 |
1928
- | 40 | 3 |
1929
- | 20 | 3 |
1930
- +--------+-------+
1931
- ```
1911
+ and the associated n-tile function::
1912
+
1913
+ +--------+-------+
1914
+ | points | ntile |
1915
+ +--------+-------+
1916
+ | 120 | 1 |
1917
+ | 100 | 1 |
1918
+ | 80 | 2 |
1919
+ | 60 | 2 |
1920
+ | 40 | 3 |
1921
+ | 20 | 3 |
1922
+ +--------+-------+
1932
1923
1933
1924
To set window function parameters use the window builder approach described in the
1934
1925
ref:`_window_functions` online documentation.
1935
1926
"""
1936
- # Developer note: ntile only accepts literal values.
1937
1927
return Expr (f .ntile (Expr .literal (groups ).expr ))
0 commit comments