meanData = all_data.groupby(['Id'])[features].agg('mean') This groups the data by 'Id' value, selects the desired features, and aggregates each group by computing the 'mean' of each group. From the documentation, I know that the argument to .agg can be a string that names a function that will be used to aggregate the data. More @Wikipedia
Hover over any link to get a description of the article. Please note that search keywords are sometimes hidden within the full article and don't appear in the description or title.