By incorporating helpful comments I came up with a solution on my own.
df.groupby(['UserID', 'ID'], as_index=False).size()df.reset_index(inplace = True)df.columns = ['UserID', 'ID', 'Counter']Expected_Output = pd.pivot('UserID', 'ID', 'Counter')