qis.get_nonnan_index

qis.get_nonnan_index(df, position='first', return_index_for_all_nans=-1)[source]

Get the first or last non-NaN index for each column/series.

Parameters:
  • df (Series | DataFrame) – series or frame to scan

  • position (Literal['first', 'last']) – which end to look from, 'first' or 'last'

  • return_index_for_all_nans (int) – positional index returned for an all-NaN column, so an empty column yields a date rather than raising. -1 gives the last index entry, 0 the first

Returns:

the timestamp for a Series, or one timestamp per column for a DataFrame

Return type:

Timestamp | List[Timestamp]