# mean ratings of beers based on number of IPA's from collection rated# i.e., some reviewers only rated 1 beer, others all 9# i myself have had 8 of 9; missing 'surly'df_ipa.groupby('ratings_cnt').mean()

# generate ratings dict and sort in desc order for creation of gridsipa_rating_score={k:vfork,vinzip(df_ipa.columns[:-1],rating_iter[-1])}ipa_rating_score=sorted(ipa_rating_score.items(),key=lambdax:(-x[1],x[0]))ipa_rating_score

# {k:v for k,v in zip(range(9), [beer[0] for beer in ipa_rating_score])}ipa_perc_sorted_df=pd.DataFrame(ipa_perc_sorted,columns=[beer[0]forbeerinipa_rating_score],index=[beer[0]forbeerinipa_rating_score])ipa_est_pref_df=pd.DataFrame(ipa_est_pref,columns=[beer[0]forbeerinipa_rating_score],index=[beer[0]forbeerinipa_rating_score])