def split_train_val(df, trn_amount, keep_order=True):
    """
    Split a dataframe in two

    :param df: Dataframe
    :param trn_amount: If a value between 0 and 1, corresponds to the percentage of the df to be used in training, if
        greater than corresponds to the number of rows in the df to be used in training
    :param keep_order: If True (default) will split the dataframe so that the training set is rows [:n] and the
        validation set is rows [n:]
    :return df_train: Portion of the dataframe used for training
    :retrun df_valid: Portion of the dataframe used for validation
    """

    # try:
    #     assert 0 <= trn_prcnt <= 1
    # except:
    #     print("trn_prcnt must be between 0 and 1")
    #     raise
    if 0 <= trn_amount <= 1:
        n_trn = int(len(df)*trn_amount)
    else:
        n_trn = trn_amount
    if not keep_order:
        df = df.sample(frac=1)
    df_train = df[:n_trn]
    df_valid = df[n_trn:]
    return [df_train, df_valid]