def groupbys(df1, df2, by=None, left_by=None, right_by=None,
    allow_right_empty=False):
    """
    df1: Left pandas.DataFrame
    df2: Right pandas.DataFrame
    by: "by" of groupby. Use intersection of each columns, if it is None.
    left_by: This or "by" is used as "by" of df1.groupby.
    right_by: This or "by" is used as "by" of df2.groupby.
    allow_right_empty: Output right, if it is empty.
    """
    if by is None:
        by = df1.columns.intersection(df2.columns).tolist()
    g1 = df1.groupby(left_by if left_by else by)
    g2 = df2.groupby(right_by if right_by else by)
    for k, v1 in g1:
        v2 = df2.iloc[g2.indices.get(k, [])]
        if allow_right_empty or len(v2):
            yield k, v1, v2
