<jupyter_start><jupyter_text>Average of BreweriesThe following function will return the average of the average rating of all the beers from a particular brewery. After the function an example will be included. Interpretation of AveragesThe highest rated brewery under the control of either Molson Coors or Miller Coors, according to https://www.beeradvocate.com/, was AC Golden Brewing Company. In fact, all of the top rated breweries are presented as 'craft breweries'. The first Coors/Molson branded brewery that came up was Coors Brewing Company (Molson-Coors), but it was still in the bottom 10 of 19 breweries. It is not surprising that the top rated breweries would be craft breweries, because https://www.beeradvocate.com/ is probably more frequented by those who enjoy craft brews.<jupyter_code>def get_average_of_breweries(df):
    breweries = df["Brewery"].unique()

    average_rating_for_breweries = []
    for brewery in breweries :
        df_1 = df.loc[molson_beers['Brewery'] == brewery]
        average_rating_for_breweries.append([brewery, df_1['Average'].mean()])

    result = pd.DataFrame(average_rating_for_breweries, columns = ['Brewery', 'Average Rating'])

    return result
get_average_of_breweries(molson_beers).sort_values(by=['Average Rating'])<jupyter_output><empty_output><jupyter_text>Average of Beer StylesThe following function will return the average of all the beers of a particular style/type of beer. After the function an example will be run. Interpretation of the ExampleThe lowest rated style is 'Low Alcohol Beer' which is not surprising to me, since I have never drank a good low alcohol beer. It does surprise me that Stout is rated so highly, because most people I know do not like stout. I am happy to see it there though since Stout is my favourite style. Quadrupel is a very good beer, but I am a bit suprised it is here because there are not many of them.Perhaps one of the later functions will determine why these rarer styles are at the top.<jupyter_code>def get_average_of_styles(df):
    styles = df["Type"].unique()

    average_rating_for_styles = []
    for style in styles :
        df_1 = df.loc[molson_beers['Type'] == style]
        average_rating_for_styles.append([style, df_1['Average'].mean()])

    result = pd.DataFrame(average_rating_for_styles, columns = ['Style', 'Average Rating'])

    return result
get_average_of_styles(molson_beers).sort_values(by=['Average Rating'])<jupyter_output><empty_output><jupyter_text>Sort and List Popular Beers from a given BreweryThe following function sorts beers from given brewery, as long as the beer has at least 50 ratings. After the function there is an example<jupyter_code>def sort_popular_beers_from_brewery(df, brewery) :
    df = df.drop(df[pd.to_numeric(df.Ratings) < 50].index)
    
    df = df.loc[df['Brewery'] == brewery]

    return df.sort_values(by=['Average'])
sort_popular_beers_from_brewery(molson_beers, 'Molson Coors Canada')<jupyter_output><empty_output><jupyter_text>Sort and List Popular Beers by StyleThe next, and final, function will sort and list beers by their style/type as long as the individual beer has at least 50 ratings. After the function a few examples will be done. InterpretationThe first example is just a look at what a common stle looks like. The two after are the two styles which were close to the top, and maybe not surprisingly there is not many entries. The Quad does not even have one entry, so none of the beers in that style have more than 50 ratings.The last two are looking at styles that had the lowest ratings. The 'Low alcohol beer' only has one entry, so I am guessing 'Low alcohol beer' is very unpopular. The 'Lager - European Pale' has a few entries, and it makes me think that it is not an unpopular style. I am guessing that there are just many different beers in the category of 'Lager - European Pale' and while none of them warrant off the charts ratings not many of them are bad.<jupyter_code>def sort_popular_beers_from_style(df, style) :
    df = df.drop(df[pd.to_numeric(df.Ratings) < 50].index)
    
    df = df.loc[df['Type'] == style]

    return df.sort_values(by=['Average'])
sort_popular_beers_from_style(molson_beers, 'Lager - Light')
sort_popular_beers_from_style(molson_beers, 'Stout - American Imperial')
sort_popular_beers_from_style(molson_beers, 'Quadrupel (Quad)')
sort_popular_beers_from_style(molson_beers, 'Low Alcohol Beer')
sort_popular_beers_from_style(molson_beers, 'Lager - European Pale')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07283595306619438, 'fraction_numerical': 0.003984945760460483, 'mean_word_length': 5.048192771084337, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 17, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '564472', 'license': 'MIT', 'n_tokens_mistral': 1385, 'n_tokens_neox': 1283, 'n_words': 536, 'path': 'Molson/good_copy_of_analysis.ipynb', 'repo_name': 'PhysicsUofRAUI/some-kaggle-notebooks', 'size': '4517'}