Stratified sampling technique alternative

Screen Link:
https://app.dataquest.io/m/283/sampling/7/stratified-sampling

I think the provided solution could be a little better.
My Code:

wnba['Pts_per_game'] = wnba['PTS'] / wnba['Games Played']
groups = wnba.groupby('Pos')
groups = dict(list(groups))
points_per_position = {}
for key in groups:
    points_per_position[key] = groups[key].sample(10, random_state=0)['Pts_per_game'].mean()
position_most_points = max(points_per_position, key = lambda x : points_per_position[x])

4 Likes

I recategorised your topic @austin-deccentric

1 Like