def pivotDiagnostic(df, index, columns, values):
    """Attempt to pivot the DataFrame. If there are duplicate
    entries in the pivot table then return a df of duplicates

    Parameters
    ----------
    df : pd.DataFrame
    index : str
    columns : str or list
    values : str or list

    Returns
    -------
    df :pd.DataFrame
        If no exception then returns pivot table,
        otherwise returns duplicate rows in df."""

    try:
        p = df.pivot(index=index, columns=columns, values=values)
        print('Pivot success: return pivoted df')
        return p
    except ValueError:
        if type(columns) in [str, str]:
            columns = [columns]
        if not isinstance(columns, list):
            columns = list(columns)

        if type(values) in [str, str]:
            values = [values]
        if not isinstance(values, list):
            values = list(values)

        dupInd = df[[index] + columns].duplicated(keep=False)
        print('Index contains %d duplicate entries, cannot reshape' % dupInd.sum())
        print('Returning duplicate rows')
        return df[[index] + columns + values].loc[dupInd].sort_values(by=[index] + columns + values)