def coalesce_table_labels(attributes, onrows, oncolumns):
    """Returns a tuple 9`onrows`, `oncolumns`) containing `attributes`. If
    both are empty, all attributes will be put on rows. If one of the two is
    empty, the rest of attributes is put on that axis."""
    if not onrows or not oncolumns:
        onrows = onrows or []
        oncolumns = oncolumns or []

        if not onrows:
            onrows = [attr for attr in attributes if attr not in oncolumns]

        if not oncolumns:
            oncolumns = [attr for attr in attributes if attr not in onrows]

    return(onrows, oncolumns)