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

modin.pandas.DataFrame.first_valid_index¶

DataFrame.first_valid_index()[source]¶

Return index for first 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.first_valid_index()
1
>>> s = pd.Series([None, None])
>>> s.first_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.first_valid_index()
10
>>> df = pd.DataFrame([5, 6, 7, 8], index=["i", "am", "iron", "man"])
>>> df.first_valid_index()
'i'
Copy