<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def union(df, other, index=False, keep='first'):
 """ Returns rows that appear in either DataFrame. Args: df (pandas.DataFrame):
 data passed in through the pipe. other (pandas.DataFrame):
 other DataFrame to use for set operation with the first. Kwargs: index (bool):
 Boolean indicating whether to consider the pandas index as part of the set operation (default `False`). keep (str):
 Indicates which duplicate should be kept. Options are `'first'` and `'last'`. """

    validate_set_ops(df, other)
    stacked = df.append(other)
    if index:
        stacked_reset_indexes = stacked.reset_index()
        index_cols = [col for col in stacked_reset_indexes.columns if col not in df.columns]
        index_name = df.index.names
        return_df = stacked_reset_indexes.drop_duplicates(keep=keep).set_index(index_cols)
        return_df.index.names = index_name
        return return_df
    else:
        return stacked.drop_duplicates(keep=keep)