You are viewing documentation about an older version (1.18.0). View latest version

modin.pandas.DataFrame.last_valid_index¶

DataFrame.last_valid_index() → Scalar | tuple[Scalar][source]¶

Return index for last non-NA value or None, if no non-NA value is found.

Return type:

scalar or None, Tuple of scalars if MultiIndex

Examples

>>> s = pd.Series([None, 3, 4])
>>> s.last_valid_index()
2
>>> s = pd.Series([None, None])
>>> s.last_valid_index()
>>> df = pd.DataFrame({'A': [None, 1, 2, None], 'B': [3, 2, 1, None]}, index=[10, 11, 12, 13])
>>> df
      A    B
10  NaN  3.0
11  1.0  2.0
12  2.0  1.0
13  NaN  NaN
>>> df.last_valid_index()
12
>>> df = pd.DataFrame([5, 6, 7, 8], index=["i", "am", "iron", "man"])
>>> df.last_valid_index()
'man'
Copy