def get_previous_value(df, group, column, name):
    """Group by a column and return the previous value of another column and assign value to a new column.

    Args:
        df: Pandas dataframe.
        group: Column name to groupby
        column: Column value to return.
        name: Name for new column.

    Returns:
        Original dataframe with new column containing previous value of named column.

    """
    df[name] = df.groupby([group])[column].shift().notnull().astype(int)
    return df
