There is a Pandas dataframe: userId movieId rating timestamp 0 1 31 2.5 1260759144 1 1 1029 3.0 1260759179 2 1 1061 3.0 1260759182 3 1 1129 2.0 1260759185 4 1 1172 4.0 1260759205 Group the data by "userId" column and output in a separate column the number of values in the "rating" column
import pandas as pd df = pd.read_csv('ratings.csv') df.groupby('userId').size().to_frame('size').reset_index()