def last_valid_index(self) -> Optional[Union[(Scalar, Tuple[(Scalar, ...)])]]:
    "\n        Return index for last non-NA/null value.\n\n        Returns\n        -------\n        scalar, tuple, or None\n\n        Notes\n        -----\n        This API only works with PySpark >= 3.0.\n\n        Examples\n        --------\n\n        Support for DataFrame\n\n        >>> psdf = ps.DataFrame({'a': [1, 2, 3, None],\n        ...                     'b': [1.0, 2.0, 3.0, None],\n        ...                     'c': [100, 200, 400, None]},\n        ...                     index=['Q', 'W', 'E', 'R'])\n        >>> psdf\n             a    b      c\n        Q  1.0  1.0  100.0\n        W  2.0  2.0  200.0\n        E  3.0  3.0  400.0\n        R  NaN  NaN    NaN\n\n        >>> psdf.last_valid_index()  # doctest: +SKIP\n        'E'\n\n        Support for MultiIndex columns\n\n        >>> psdf.columns = pd.MultiIndex.from_tuples([('a', 'x'), ('b', 'y'), ('c', 'z')])\n        >>> psdf\n             a    b      c\n             x    y      z\n        Q  1.0  1.0  100.0\n        W  2.0  2.0  200.0\n        E  3.0  3.0  400.0\n        R  NaN  NaN    NaN\n\n        >>> psdf.last_valid_index()  # doctest: +SKIP\n        'E'\n\n        Support for Series.\n\n        >>> s = ps.Series([1, 2, 3, None, None], index=[100, 200, 300, 400, 500])\n        >>> s\n        100    1.0\n        200    2.0\n        300    3.0\n        400    NaN\n        500    NaN\n        dtype: float64\n\n        >>> s.last_valid_index()  # doctest: +SKIP\n        300\n\n        Support for MultiIndex\n\n        >>> midx = pd.MultiIndex([['lama', 'cow', 'falcon'],\n        ...                       ['speed', 'weight', 'length']],\n        ...                      [[0, 0, 0, 1, 1, 1, 2, 2, 2],\n        ...                       [0, 1, 2, 0, 1, 2, 0, 1, 2]])\n        >>> s = ps.Series([250, 1.5, 320, 1, 0.3, None, None, None, None], index=midx)\n        >>> s\n        lama    speed     250.0\n                weight      1.5\n                length    320.0\n        cow     speed       1.0\n                weight      0.3\n                length      NaN\n        falcon  speed       NaN\n                weight      NaN\n                length      NaN\n        dtype: float64\n\n        >>> s.last_valid_index()  # doctest: +SKIP\n        ('cow', 'weight')\n        "
    data_spark_columns = self._internal.data_spark_columns
    if (len(data_spark_columns) == 0):
        return None
    cond = reduce((lambda x, y: (x & y)), map((lambda x: x.isNotNull()), data_spark_columns))
    last_valid_rows = self._internal.spark_frame.filter(cond).select(self._internal.index_spark_columns).tail(1)
    if (len(last_valid_rows) == 0):
        return None
    last_valid_row = last_valid_rows[0]
    if (len(last_valid_row) == 1):
        return last_valid_row[0]
    else:
        return tuple(last_valid_row)
Return index for last non-NA/null value.

Returns
-------
scalar, tuple, or None

Notes
-----
This API only works with PySpark >= 3.0.

Examples
--------

Support for DataFrame

>>> psdf = ps.DataFrame({'a': [1, 2, 3, None],
...                     'b': [1.0, 2.0, 3.0, None],
...                     'c': [100, 200, 400, None]},
...                     index=['Q', 'W', 'E', 'R'])
>>> psdf
     a    b      c
Q  1.0  1.0  100.0
W  2.0  2.0  200.0
E  3.0  3.0  400.0
R  NaN  NaN    NaN

>>> psdf.last_valid_index()  # doctest: +SKIP
'E'

Support for MultiIndex columns

>>> psdf.columns = pd.MultiIndex.from_tuples([('a', 'x'), ('b', 'y'), ('c', 'z')])
>>> psdf
     a    b      c
     x    y      z
Q  1.0  1.0  100.0
W  2.0  2.0  200.0
E  3.0  3.0  400.0
R  NaN  NaN    NaN

>>> psdf.last_valid_index()  # doctest: +SKIP
'E'

Support for Series.

>>> s = ps.Series([1, 2, 3, None, None], index=[100, 200, 300, 400, 500])
>>> s
100    1.0
200    2.0
300    3.0
400    NaN
500    NaN
dtype: float64

>>> s.last_valid_index()  # doctest: +SKIP
300

Support for MultiIndex

>>> midx = pd.MultiIndex([['lama', 'cow', 'falcon'],
...                       ['speed', 'weight', 'length']],
...                      [[0, 0, 0, 1, 1, 1, 2, 2, 2],
...                       [0, 1, 2, 0, 1, 2, 0, 1, 2]])
>>> s = ps.Series([250, 1.5, 320, 1, 0.3, None, None, None, None], index=midx)
>>> s
lama    speed     250.0
        weight      1.5
        length    320.0
cow     speed       1.0
        weight      0.3
        length      NaN
falcon  speed       NaN
        weight      NaN
        length      NaN
dtype: float64

>>> s.last_valid_index()  # doctest: +SKIP
('cow', 'weight')
def last_valid_index(self) -> Optional[Union[(Scalar, Tuple[(Scalar, ...)])]]:
    "\n        Return index for last non-NA/null value.\n\n        Returns\n        -------\n        scalar, tuple, or None\n\n        Notes\n        -----\n        This API only works with PySpark >= 3.0.\n\n        Examples\n        --------\n\n        Support for DataFrame\n\n        >>> psdf = ps.DataFrame({'a': [1, 2, 3, None],\n        ...                     'b': [1.0, 2.0, 3.0, None],\n        ...                     'c': [100, 200, 400, None]},\n        ...                     index=['Q', 'W', 'E', 'R'])\n        >>> psdf\n             a    b      c\n        Q  1.0  1.0  100.0\n        W  2.0  2.0  200.0\n        E  3.0  3.0  400.0\n        R  NaN  NaN    NaN\n\n        >>> psdf.last_valid_index()  # doctest: +SKIP\n        'E'\n\n        Support for MultiIndex columns\n\n        >>> psdf.columns = pd.MultiIndex.from_tuples([('a', 'x'), ('b', 'y'), ('c', 'z')])\n        >>> psdf\n             a    b      c\n             x    y      z\n        Q  1.0  1.0  100.0\n        W  2.0  2.0  200.0\n        E  3.0  3.0  400.0\n        R  NaN  NaN    NaN\n\n        >>> psdf.last_valid_index()  # doctest: +SKIP\n        'E'\n\n        Support for Series.\n\n        >>> s = ps.Series([1, 2, 3, None, None], index=[100, 200, 300, 400, 500])\n        >>> s\n        100    1.0\n        200    2.0\n        300    3.0\n        400    NaN\n        500    NaN\n        dtype: float64\n\n        >>> s.last_valid_index()  # doctest: +SKIP\n        300\n\n        Support for MultiIndex\n\n        >>> midx = pd.MultiIndex([['lama', 'cow', 'falcon'],\n        ...                       ['speed', 'weight', 'length']],\n        ...                      [[0, 0, 0, 1, 1, 1, 2, 2, 2],\n        ...                       [0, 1, 2, 0, 1, 2, 0, 1, 2]])\n        >>> s = ps.Series([250, 1.5, 320, 1, 0.3, None, None, None, None], index=midx)\n        >>> s\n        lama    speed     250.0\n                weight      1.5\n                length    320.0\n        cow     speed       1.0\n                weight      0.3\n                length      NaN\n        falcon  speed       NaN\n                weight      NaN\n                length      NaN\n        dtype: float64\n\n        >>> s.last_valid_index()  # doctest: +SKIP\n        ('cow', 'weight')\n        "
    data_spark_columns = self._internal.data_spark_columns
    if (len(data_spark_columns) == 0):
        return None
    cond = reduce((lambda x, y: (x & y)), map((lambda x: x.isNotNull()), data_spark_columns))
    last_valid_rows = self._internal.spark_frame.filter(cond).select(self._internal.index_spark_columns).tail(1)
    if (len(last_valid_rows) == 0):
        return None
    last_valid_row = last_valid_rows[0]
    if (len(last_valid_row) == 1):
        return last_valid_row[0]
    else:
        return tuple(last_valid_row)