<jupyter_start><jupyter_text>Bruins StatsYears 2015 - Present<jupyter_code>%matplotlib inline

import pandas as pd
import matplotlib.pyplot as plt
from datetime import datetime
from tabulate import tabulate
plt.style.use('seaborn-bright')
# setting url data

url_2015 = 'https://www.hockey-reference.com/teams/BOS/2015_games.html'
url_2016 = 'https://www.hockey-reference.com/teams/BOS/2016_games.html'
url_2017 = 'https://www.hockey-reference.com/teams/BOS/2017_games.html'
url_2018 = 'https://www.hockey-reference.com/teams/BOS/2018_games.html'
url_2019 = 'https://www.hockey-reference.com/teams/BOS/2019_games.html'
url_2020 = 'https://www.hockey-reference.com/teams/BOS/2020_games.html'

# creating dataframe for each year
df_2015 = pd.read_html(url_2015)[0]
df_2016 = pd.read_html(url_2016)[0]
df_2017 = pd.read_html(url_2017)[0]
df_2018 = pd.read_html(url_2018)[0]
df_2019 = pd.read_html(url_2019)[0]
df_2020 = pd.read_html(url_2020)[0]
#df_2020 = df_2020.drop(columns=['Time']) # dropping time column to match

# rename columns to match
#df_2020.rename(columns = {'Unnamed: 7': 'Unnamed: 6', 'Unnamed: 8': 'Unnamed: 7'}, inplace=True)

years = [df_2015,df_2016,df_2017,df_2018,df_2019,df_2020]

b_data = pd.concat(years, sort=False)

b_data = b_data[b_data.GP != 'GP']

b_data.rename(columns = {'Unnamed: 6':'Result', 'Unnamed: 7': 'OT_SO'}, inplace = True)<jupyter_output><empty_output><jupyter_text>Total Games Played<jupyter_code>tgp = b_data['Result'].count()
print(" " , tgp)<jupyter_output>480<jupyter_text>Wins vs Loss<jupyter_code>w_l = b_data['Result'].value_counts().values
print('Wins:',w_l[0],'Loss:',w_l[1])
b_data['Result'].value_counts().plot(kind='bar', color=['gold', 'red']);<jupyter_output>Wins: 270 Loss: 210<jupyter_text>OT vs SO<jupyter_code>b_data.groupby('Result')['OT_SO'].value_counts().unstack().plot(kind='bar', color=['gold','red']);
def opp_team(team):
    opp_games = b_data[b_data['Opponent'].str.contains(team)]
    opp_games = opp_games.sort_values(by='Date')
    opp_games[['GF','GA']] = opp_games[['GF','GA']].apply(pd.to_numeric)
    game_count = opp_games['Result'].value_counts()
    goals = opp_games[['GF','GA']].sum()
    total_games = opp_games['Result'].count()
    total_wins = opp_games['Result'].str.contains('W').sum()
   
    

    print()
    print(tabulate(opp_games.iloc[:,[1,3,4,5,6,7]], headers='keys', tablefmt='psql', showindex=False))
    print()
    print(game_count.to_string())
    
    plt.figure(figsize=(8,8))
    plt.subplot(3, 1, 1)
    game_count.plot(kind='bar', color=['gold', 'red'])
    plt.title('Wins vs Loss')
    plt.show()
    
    print()
    print(goals.to_string())
    plt.figure(figsize=(8,8))
    plt.subplot(3, 1, 2)
    goals.plot(kind='bar', color=['gold', 'red'])
    plt.title('Total Goals')
    plt.show()
    
    plt.figure(figsize=(8,8))
    plt.subplot(3,1,2)
    opp_games.groupby('Result')['OT_SO'].value_counts().plot(kind='bar')
    plt.show()<jupyter_output><empty_output><jupyter_text>Opponent<jupyter_code>opp_team('Florida')<jupyter_output>+------------+------------------+------+------+----------+---------+
| Date       | Opponent         |   GF |   GA | Result   | OT_SO   |
|------------+------------------+------+------+----------+---------|
| 2014-11-04 | Florida Panthers |    2 |    1 | W        | OT      |
| 2015-03-21 | Florida Panthers |    1 |    2 | L        | SO      |
| 2015-03-31 | Florida Panthers |    3 |    2 | W        | nan     |
| 2015-04-09 | Florida Panthers |    2 |    4 | L        | nan     |
| 2015-10-30 | Florida Panthers |    3 |    1 | W        | nan     |
| 2015-12-12 | Florida Panthers |    3 |    1 | W        | nan     |
| 2016-03-07 | Florida Panthers |    5 |    4 | W        | OT      |
| 2016-03-24 | Florida Panthers |    1 |    4 | L        | nan     |
| 2016-11-01 | Florida Panthers |    2 |    1 | W        | nan     |
| 2016-12-05 | Florida Panthers |    4 |    3 | W        | OT      |
| 2016-12-22 | Florida Panthers |    3 |    1 | W        | nan     |
| 2017-01-07 | Florida Panthers |[...]
{'fraction_non_alphanumeric': 0.20296296296296296, 'fraction_numerical': 0.07358024691358024, 'mean_word_length': 3.129459734964322, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 6, 'lorem ipsum': 0, 'www.': 6, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '157880', 'license': 'MIT', 'n_tokens_mistral': 1765, 'n_tokens_neox': 1520, 'n_words': 245, 'path': 'Bruins_Analysis.ipynb', 'repo_name': 'chadless1/jupyter_notebooks', 'size': '4050'}