(df: pd.DataFrame)
return df
If df index is not a simple RangeIndex (or similar), include it into a table
If df index is not a simple RangeIndex (or similar), include it into a table
If df index is not a simple RangeIndex ( or similar ) include it into a table
def _reset_index(df: pd.DataFrame) -> pd.DataFrame:
    """If df index is not a simple RangeIndex (or similar), include it into a table"""
    if (
        # not range-like index - test first to skip slow startswith(_o) check
        not (
            df.index.is_integer()
            and (df.index.is_monotonic_increasing or df.index.is_monotonic_decreasing)
        )
        # check that it does not contain Orange index
        and (
            # startswith is slow (for long dfs) - firs check if col has strings
            isinstance(df.index, pd.MultiIndex)
            or not is_string_dtype(df.index)
            or not any(str(i).startswith("_o") for i in df.index)
        )
    ):
        df = df.reset_index()
    return df
def _reset_index ( df : pd . DataFrame ) -> pd . DataFrame : if ( # not range-like index - test first to skip slow startswith(_o) check not ( df . index . is_integer ( ) and ( df . index . is_monotonic_increasing or df . index . is_monotonic_decreasing ) ) # check that it does not contain Orange index and ( # startswith is slow (for long dfs) - firs check if col has strings isinstance ( df . index , pd . MultiIndex ) or not is_string_dtype ( df . index ) or not any ( str ( i ) . startswith ( "_o" ) for i in df . index ) ) ) : df = df . reset_index ( ) return df