<jupyter_start><jupyter_text>Task 5: Conduct your analysis  Research Questions:- What is the best team at home?- What is the most competative league?- What is the least competative league?- Who overcame the biggeset negative pitcher adjusted rating in comparison to his opponent to win a World Series?- Who had the biggest pitcher adjusted rating advantage in comparison to his opponent and wonn a World Series game?- Who was the worst pitcher in terms of rolling game score to win a game in the world series?- Who was the best pitcher in terms of rolling game score to lose a game in the world series?  Who is the best team? Part 1: The New York Yankees> Looking at the graph from our EDA     Without any doubt it is easy to see that the New York Yankees (NYY) are by far the highest rated team playing at home and away, scoring an average rating of ~1538 which is aproximately 15% higher than the San Fransico Giants (SFG) the next highest rated team. However we can continue to dive deeper into the statistics, such as are the Yankees always good? Or did they just have an incredible stretch of time where they were heads and shoulders above everyone else?  By drawing from our EDA we can look at the rating of the NYY throughout there entire teams history.    The Red Line shows the 1500 mark or league average.  As the graph clearly shows, the NYY have consistently been one of the best teams in the league.  Once the team got over the initial starting hump almost every new team faces they only dipped below league average on two occations once from 1967-1968 and again from 1989-1992.  That means the Yankees have only been below average 6% of the time in the last 100 years.  This statistic also is representative in their championships, the Yankees as a team have won a whopping 27 world series rings, the most anyone has every won by far. Thus, the Yankees have historically been by far the best and most consistent team in baseball.     Part 2: The Current Year  The New York Yankees have historically been the best team, however what team would claim that title now?  Has the best team still been the Yankees in the past 3 years?    > Once again we can turn to out EDA to find out      The following three images show the average rating of each team from 2018-2020, and as it turns out the best team in the last 3 years has been The Houston Astros*, but with the rise of their cheating scandel I dont believe we can honestly call them the best team in the curretn year, thus I will remove them from the running.  This leaves the Dodgers, who remained in 3rd place every year, logically this makes sense as the Dodgers just won the world series and have clintched their division title every year for the past 8 years. Furthermore, they have averaged a 1553 rating in the past 3 years which is insane, and puts them far ahead of anyone in the lifetime graph up above.  I fully expect the Dodgers to continue their success into the next year as they are statistically the best team in baseball in the current year.  What is the most/least competative league in 2020? What was the competative league in 2020?To find the most compative league we have to look at the ratings of each team in each league.  The smaller the differences between each league the more competative the league should be. > The National League EastNow based purlely on the difference between each team, the NL East has 4 teams within striking distance of each other.  Furthermore, the top two teams in this league are practically overlapping, meaning this has the possibility to not only be a competative league but a fun league to watch as according to the statistics it is practically a coin toss to see if ATL and WSN will take the division title.  Furthermore, we can also see that the NYM are also making there way up the ladder as well creating even more competition for the 2021 season and beyond. What was the least cometative league in 2020> Once again we can use our EDA which can show us The NL WestAs show the National League West at first seems to be extremely competative as there are four teams with ratings that are basically overlapping one another. However, in the world of baseball it does not matter how close the teams are if there is one outlier since only one team can take the division title.  Therefore, since the Dodgers are basically out of everyones league they are all competeing for second place, which is not very fun.  Furthermore, history also tells us that this league is not very competative since the Dodgers have clitched 8 straight division titles.  The largest negative differential in pitcher adjusted ratings to win a World Series Game  <NAME> (SFG) vs <NAME> (DET)B<NAME> came into this game with an adjusted pitcher rating of -14.777 while <NAME> who was one of the best pitchers of his generation entered the game with a rating of 40.35. Verlander was the better pitcher while Zito probably shouldn't have been pitching this game. Despite the odds Zito came away with a 5 run victory winning the game 8-3. The 2nd largest differential that was overcome <NAME> (SDP) vs <NAME> (NYY)The San Diego Padre's Kevin Brown was an above average strter while <NAME> with an adjusted rating of 12.389 was most often in over his head and gave his to an adjusted rating of -20.116. The Padres failed to capitilize on the pitching at all getting shutout 3-0. The biggest positive differential in pitcher adjusted ratings was won by cheaters!  <NAME> (WSN) vs <NAME> (HOU)The 2019 Houston Astros used cameras to steal signs and signal the Astro's pitcher for when a change-up would be pitched, a change-up is often considered easy to hit as they are much slower giving the batter more time to line up the ball. So while they do go down in the record books as having overcome the biggeset difference in pitcher adjusted ratings to their team, there is a **HUGE** asteriks on that game. The Houston Astros pitcher for this game.  That being said their pitcher <NAME> is a fantistic pitcher and had an adjusted pitcher rating of 47.888, while his opponent <NAME> was not an amzing pitcher having an adusted pitcher rating of -29.811 and going up against a team of cheaters probably did not help his cause. This game wasn't close as the Astros were able to put up 2 runs in the 2nd inning and another 2 in the 4th inning sealing the game as the Nationals were not able to get any offense going against the dominant Cole.![Astros.png](attachment:ef42e6eb-3a2f-412a-950d-bb62911f08c8.png) The 2nd biggest postivive difference in adjusted pitcher ratings This game came quite rcently as well, when the Chicago White Sox won a game 7 - 2 with a a difference of pitcher adjusted ratings of 44.58, this falls well short of the cheating Astros who had a pitcher difference of 77.699.<jupyter_code>import pandas as pd
import numpy as np
df5 = pd.read_csv("../../data/processed/ws_pitcher_adj_difference.csv")
df6 = df5.drop(["home_pitcher_rating", "away_pitcher_rating", "win_pitch_adj", "pitcher_difference"], axis="columns")


win_pitch = np.where(df6["home_win"] == True, (df5["home_pitcher_rgs"]), (df5["away_pitcher_rgs"]))
df6["win_pitch_rgs"] = win_pitch

lose_pitch = np.where(df6["away_win"] == True, (df5["home_pitcher_rgs"]), (df5["away_pitcher_rgs"]))
df6["lose_pitch_rgs"] = lose_pitch

df6 = df6.sort_values(by="win_pitch_rgs", ascending = True)
print(df6)<jupyter_output>Unnamed: 0        date  season home_team away_team home_pitcher  \
563      143450   10/4/1947    1947       LAD       NYY     barnr103   
264       78402  10/22/1986    1986       BOS       NYM     nippa001   
273       45297  10/30/2001    2001       NYY       ARI     clemr001   
574       82646  10/13/1984    1984       DET       SDP     morrj001   
430      163280   10/7/1931    1931       OAK       STL     hoytw101   
..          ...         ...     ...       ...       ...          ...   
478      119338   10/7/1965    1965       MIN       LAD     kaatj101   
579       52679  10/17/1998    1998       NYY       SDP     welld001   
438      114455  10/10/1968    1968       STL       DET     gibsb101   
616         957  10/22/2019    2019       HOU       WSN  <NAME>   
585       59738  10/26/1995    1995       CLE       ATL     herso001   

     away_pitcher  home_pitcher_rgs  away_pitcher_rgs  home_score  away_score  \
563      sheas101            42.575            53.353 [...]<jupyter_text><NAME> <NAME> entered this game on October 14th, 1979 with a rolling game score of 44.814, if he won this game he would go down as the new leader for worst pitcher to win a world series game.The record holder before <NAME>, was held by <NAME> and he set the record 4 years prior to Rooker taking the mound that fateful Sunday. He pitched well and only surrendured 1 run on 3 hits. His counterpart did not fare so well and the Pirates ccruised to a 7-1 victory for game 5, taking a 3-2 lead in the series.![Screenshot (78).png](attachment:5dd6d3b9-05f3-46b3-9ee4-666799caaeaa.png)![Screenshot (78)-2.png](attachment:5d4ae3ec-5b24-43b5-afce-74c5b46b47d2.png)  Now to find the best pitcher in terms of rolling game score to lose a game in the World Series<jupyter_code>df6 = df6.sort_values(by="lose_pitch_rgs", ascending = False)
print(df6)<jupyter_output>Unnamed: 0        date  season home_team away_team home_pitcher  \
585       59738  10/26/1995    1995       CLE       ATL     herso001   
616         957  10/22/2019    2019       HOU       WSN  <NAME>   
438      114455  10/10/1968    1968       STL       DET     gibsb101   
579       52679  10/17/1998    1998       NYY       SDP     welld001   
478      119338   10/7/1965    1965       MIN       LAD     kaatj101   
..          ...         ...     ...       ...       ...          ...   
430      163280   10/7/1931    1931       OAK       STL     hoytw101   
574       82646  10/13/1984    1984       DET       SDP     morrj001   
273       45297  10/30/2001    2001       NYY       ARI     clemr001   
264       78402  10/22/1986    1986       BOS       NYM     nippa001   
563      143450   10/4/1947    1947       LAD       NYY     barnr103   

     away_pitcher  home_pitcher_rgs  away_pitcher_rgs  home_score  away_score  \
585      maddg002            58.477            70.266 [...]<jupyter_text>The best pitcher in terms of rolling game Score to lose a game in the World Series is <NAME> IV - Cleveland IndiansOrel had an oustanding rgs of 70.266, which is the highest rolling game score to enter a World Series Game. Orel was one of the best pitchers of the year potentially ever, and he lost when it matteres most.The Cleveland Indians entered game 5 tied 2-2 against the Atlanta Braves with the best pitcher to ever take the mound in a World Series Game. It didn't matter, The Indians lost game 5 by a score of 5-4 and would go on to lose game 6 and the Championship.<jupyter_code>![gettyimages-51686211-594x594-1.jpg](attachment:606a9633-4a6e-4359-9f0e-6803622b23a6.jpg)<jupyter_output>'[gettyimages-51686211-594x594-1.jpg]' is not recognized as an internal or external command,
operable program or batch file.
{'fraction_non_alphanumeric': 0.04497020046956836, 'fraction_numerical': 0.06980314249593643, 'mean_word_length': 3.1094619666048238, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '347666', 'license': 'MIT', 'n_tokens_mistral': 3574, 'n_tokens_neox': 2956, 'n_words': 1640, 'path': 'analysis/submitted/Research_Questions.ipynb', 'repo_name': 'data301-2020-winter2/course-project-group_1040', 'size': '11180'}