def rank(self, method: str='average', ascending: bool=True, numeric_only: Optional[bool]=None) -> 'DataFrame':
    "\n        Compute numerical data ranks (1 through n) along axis. Equal values are\n        assigned a rank that is the average of the ranks of those values.\n\n        .. note:: the current implementation of rank uses Spark's Window without\n            specifying partition specification. This leads to move all data into\n            single partition in single machine and could cause serious\n            performance degradation. Avoid this method against very large dataset.\n\n        Parameters\n        ----------\n        method : {'average', 'min', 'max', 'first', 'dense'}\n            * average: average rank of group\n            * min: lowest rank in group\n            * max: highest rank in group\n            * first: ranks assigned in order they appear in the array\n            * dense: like 'min', but rank always increases by 1 between groups\n        ascending : boolean, default True\n            False for ranks by high (1) to low (N)\n        numeric_only : bool, optional\n            For DataFrame objects, rank only numeric columns if set to True.\n\n        Returns\n        -------\n        ranks : same type as caller\n\n        Examples\n        --------\n        >>> df = ps.DataFrame({'A': [1, 2, 2, 3], 'B': [4, 3, 2, 1]}, columns=['A', 'B'])\n        >>> df\n           A  B\n        0  1  4\n        1  2  3\n        2  2  2\n        3  3  1\n\n        >>> df.rank().sort_index()\n             A    B\n        0  1.0  4.0\n        1  2.5  3.0\n        2  2.5  2.0\n        3  4.0  1.0\n\n        If method is set to 'min', it use lowest rank in group.\n\n        >>> df.rank(method='min').sort_index()\n             A    B\n        0  1.0  4.0\n        1  2.0  3.0\n        2  2.0  2.0\n        3  4.0  1.0\n\n        If method is set to 'max', it use highest rank in group.\n\n        >>> df.rank(method='max').sort_index()\n             A    B\n        0  1.0  4.0\n        1  3.0  3.0\n        2  3.0  2.0\n        3  4.0  1.0\n\n        If method is set to 'dense', it leaves no gaps in group.\n\n        >>> df.rank(method='dense').sort_index()\n             A    B\n        0  1.0  4.0\n        1  2.0  3.0\n        2  2.0  2.0\n        3  3.0  1.0\n\n        If numeric_only is set to 'True', rank only numeric columns.\n\n        >>> df = ps.DataFrame({'A': [1, 2, 2, 3], 'B': ['a', 'b', 'd', 'c']}, columns= ['A', 'B'])\n        >>> df\n           A  B\n        0  1  a\n        1  2  b\n        2  2  d\n        3  3  c\n        >>> df.rank(numeric_only=True)\n             A\n        0  1.0\n        1  2.5\n        2  2.5\n        3  4.0\n        "
    if numeric_only:
        numeric_col_names = []
        for label in self._internal.column_labels:
            psser = self._psser_for(label)
            if isinstance(psser.spark.data_type, (NumericType, BooleanType)):
                numeric_col_names.append(psser.name)
    psdf = (self[numeric_col_names] if numeric_only else self)
    return psdf._apply_series_op((lambda psser: psser._rank(method=method, ascending=ascending)), should_resolve=True)
Compute numerical data ranks (1 through n) along axis. Equal values are
assigned a rank that is the average of the ranks of those values.

.. note:: the current implementation of rank uses Spark's Window without
    specifying partition specification. This leads to move all data into
    single partition in single machine and could cause serious
    performance degradation. Avoid this method against very large dataset.

Parameters
----------
method : {'average', 'min', 'max', 'first', 'dense'}
    * average: average rank of group
    * min: lowest rank in group
    * max: highest rank in group
    * first: ranks assigned in order they appear in the array
    * dense: like 'min', but rank always increases by 1 between groups
ascending : boolean, default True
    False for ranks by high (1) to low (N)
numeric_only : bool, optional
    For DataFrame objects, rank only numeric columns if set to True.

Returns
-------
ranks : same type as caller

Examples
--------
>>> df = ps.DataFrame({'A': [1, 2, 2, 3], 'B': [4, 3, 2, 1]}, columns=['A', 'B'])
>>> df
   A  B
0  1  4
1  2  3
2  2  2
3  3  1

>>> df.rank().sort_index()
     A    B
0  1.0  4.0
1  2.5  3.0
2  2.5  2.0
3  4.0  1.0

If method is set to 'min', it use lowest rank in group.

>>> df.rank(method='min').sort_index()
     A    B
0  1.0  4.0
1  2.0  3.0
2  2.0  2.0
3  4.0  1.0

If method is set to 'max', it use highest rank in group.

>>> df.rank(method='max').sort_index()
     A    B
0  1.0  4.0
1  3.0  3.0
2  3.0  2.0
3  4.0  1.0

If method is set to 'dense', it leaves no gaps in group.

>>> df.rank(method='dense').sort_index()
     A    B
0  1.0  4.0
1  2.0  3.0
2  2.0  2.0
3  3.0  1.0

If numeric_only is set to 'True', rank only numeric columns.

>>> df = ps.DataFrame({'A': [1, 2, 2, 3], 'B': ['a', 'b', 'd', 'c']}, columns= ['A', 'B'])
>>> df
   A  B
0  1  a
1  2  b
2  2  d
3  3  c
>>> df.rank(numeric_only=True)
     A
0  1.0
1  2.5
2  2.5
3  4.0
def rank(self, method: str='average', ascending: bool=True, numeric_only: Optional[bool]=None) -> 'DataFrame':
    "\n        Compute numerical data ranks (1 through n) along axis. Equal values are\n        assigned a rank that is the average of the ranks of those values.\n\n        .. note:: the current implementation of rank uses Spark's Window without\n            specifying partition specification. This leads to move all data into\n            single partition in single machine and could cause serious\n            performance degradation. Avoid this method against very large dataset.\n\n        Parameters\n        ----------\n        method : {'average', 'min', 'max', 'first', 'dense'}\n            * average: average rank of group\n            * min: lowest rank in group\n            * max: highest rank in group\n            * first: ranks assigned in order they appear in the array\n            * dense: like 'min', but rank always increases by 1 between groups\n        ascending : boolean, default True\n            False for ranks by high (1) to low (N)\n        numeric_only : bool, optional\n            For DataFrame objects, rank only numeric columns if set to True.\n\n        Returns\n        -------\n        ranks : same type as caller\n\n        Examples\n        --------\n        >>> df = ps.DataFrame({'A': [1, 2, 2, 3], 'B': [4, 3, 2, 1]}, columns=['A', 'B'])\n        >>> df\n           A  B\n        0  1  4\n        1  2  3\n        2  2  2\n        3  3  1\n\n        >>> df.rank().sort_index()\n             A    B\n        0  1.0  4.0\n        1  2.5  3.0\n        2  2.5  2.0\n        3  4.0  1.0\n\n        If method is set to 'min', it use lowest rank in group.\n\n        >>> df.rank(method='min').sort_index()\n             A    B\n        0  1.0  4.0\n        1  2.0  3.0\n        2  2.0  2.0\n        3  4.0  1.0\n\n        If method is set to 'max', it use highest rank in group.\n\n        >>> df.rank(method='max').sort_index()\n             A    B\n        0  1.0  4.0\n        1  3.0  3.0\n        2  3.0  2.0\n        3  4.0  1.0\n\n        If method is set to 'dense', it leaves no gaps in group.\n\n        >>> df.rank(method='dense').sort_index()\n             A    B\n        0  1.0  4.0\n        1  2.0  3.0\n        2  2.0  2.0\n        3  3.0  1.0\n\n        If numeric_only is set to 'True', rank only numeric columns.\n\n        >>> df = ps.DataFrame({'A': [1, 2, 2, 3], 'B': ['a', 'b', 'd', 'c']}, columns= ['A', 'B'])\n        >>> df\n           A  B\n        0  1  a\n        1  2  b\n        2  2  d\n        3  3  c\n        >>> df.rank(numeric_only=True)\n             A\n        0  1.0\n        1  2.5\n        2  2.5\n        3  4.0\n        "
    if numeric_only:
        numeric_col_names = []
        for label in self._internal.column_labels:
            psser = self._psser_for(label)
            if isinstance(psser.spark.data_type, (NumericType, BooleanType)):
                numeric_col_names.append(psser.name)
    psdf = (self[numeric_col_names] if numeric_only else self)
    return psdf._apply_series_op((lambda psser: psser._rank(method=method, ascending=ascending)), should_resolve=True)