import random


def split_dataframe(df,test_ratio):
    """
    split dataframe

    Parameters
    -----------------
    df: dataframe
       dataframe to be split 
    test_ratio: float
        0-1
    Returns
    -----------------
    train_df: dataframe
        train dataset
    test_df: dataframe
        test dataset
    """
    random.seed(0)
    data_size=df.shape[0]
    test_cases=random.sample(list(range(data_size)),int(data_size*test_ratio))
    train_cases=list(set(list(range(data_size)))-set(test_cases))

    test_cases=[True if i in test_cases else False for i in range(data_size)]
    train_cases=[True if i in train_cases else False for i in range(data_size)]

    train_df=df[train_cases]
    test_df=df[test_cases]
    
    return train_df,test_df