def anti_join(df, other, **kwargs):
    """
    Returns all of the rows in the left DataFrame that do not have a
    match in the right DataFrame.

    Args:
        df (pandas.DataFrame): Left DataFrame (passed in via pipe)
        other (pandas.DataFrame): Right DataFrame

    Kwargs:
        by (str or list): Columns to join on. If a single string, will join
            on that column. If a list of lists which contain strings or
            integers, the right/left columns to join on.

    Example:
        a >> anti_join(b, by='x1')

          x1  x2
        2  C   3
    """

    left_on, right_on, suffixes = get_join_parameters(kwargs)
    if not right_on:
        right_on = [col_name for col_name in df.columns.values.tolist() if col_name in other.columns.values.tolist()]
        left_on = right_on
    elif not isinstance(right_on, (list, tuple)):
        right_on = [right_on]
    other_reduced = other[right_on].drop_duplicates()
    joined = df.merge(other_reduced, how='left', left_on=left_on,
                      right_on=right_on, suffixes=('', '_y'),
                      indicator=True).query('_merge=="left_only"')[df.columns.values.tolist()]
    return joined
def anti_join ( df , other , ** kwargs ) : left_on , right_on , suffixes = get_join_parameters ( kwargs ) if not right_on : right_on = [ col_name for col_name in df . columns . values . tolist ( ) if col_name in other . columns . values . tolist ( ) ] left_on = right_on elif not isinstance ( right_on , ( list , tuple ) ) : right_on = [ right_on ] other_reduced = other [ right_on ] . drop_duplicates ( ) joined = df . merge ( other_reduced , how = 'left' , left_on = left_on , right_on = right_on , suffixes = ( '' , '_y' ) , indicator = True ) . query ( '_merge=="left_only"' ) [ df . columns . values . tolist ( ) ] return joined
Returns all of the rows in the left DataFrame that do not have a
    match in the right DataFrame.

    Args:
        df (pandas.DataFrame): Left DataFrame (passed in via pipe)
        other (pandas.DataFrame): Right DataFrame

    Kwargs:
        by (str or list): Columns to join on. If a single string, will join
            on that column. If a list of lists which contain strings or
            integers, the right/left columns to join on.

    Example:
        a >> anti_join(b, by='x1')

          x1  x2
        2  C   3