<jupyter_start><jupyter_text><NAME>  Research question/interestsI played baseball as my main sport and many others growing up. Statistics were always followed and always were worked on to get the attention of scouts or to see improvement.This data set completley outlines every statistic that is needed in baseball in regarding to players. This Data set is up to date and is easy to sort through and read. Although players names arent directly stated by looking at their playerID and a bit of knowledge about baseball you can tell which player it is. My Research questions grew and changed as I looked through the data. I seemed to overcomplicate it and went in over my head. I had to simplify and go back to create the questions I have now.Which state has the most fields used in the mlb?What players have the most games played in the field since 2000?What positions record the most putouts? (This will tell me where the most outs are made.<jupyter_code>import pandas as pd
pd.__version__
Batting = pd.read_csv("../data/raw/Batting.csv")
Batting
Pitching = pd.read_csv("../data/raw/Pitching.csv")
Pitching
Salaries = pd.read_csv("../data/raw/Salaries.csv")
Salaries
Fielding = pd.read_csv("../data/raw/Fielding.csv")
Teams = pd.read_csv("../data/raw/Teams.csv")
FieldingOF = pd.read_csv("../data/raw/FieldingOF.csv")<jupyter_output><empty_output><jupyter_text>Milestone 3<jupyter_code>import numpy as np
import pandas as pd
import matplotlib.pylab as plt
import seaborn as sns #Understanding my variables<jupyter_output><empty_output><jupyter_text>Task 1 EDA  Parks EDA<jupyter_code>parks1 = pd.read_csv("../data/raw/Parks.csv")
parks1.head()
parks1.describe()
parks1.shape
parks1.columns
parks1['state'].value_counts() #How many parks are in each state shows how popular it is in each place. 
                               #More fields = more people wanting to play / watch the game.<jupyter_output><empty_output><jupyter_text>Fielding EDA<jupyter_code>fielding1 = pd.read_csv("../data/raw/fielding.csv")
fielding1.head()
fielding1.describe()
fielding1.shape
fielding1.columns<jupyter_output><empty_output><jupyter_text>Analysis of Games Played<jupyter_code>sns.set_theme(style="ticks",
              font_scale=1.0, 
             )
sns.displot(fielding1["G"], kde = True, bins = 10)
#We can see that there are a crazy amount of players that have played under 25 games 
#and that those can be eliminated in the next process of analysing the data.<jupyter_output><empty_output><jupyter_text>Analysis of Put Outs<jupyter_code>sns.scatterplot(data = fielding1, x = "G", y = "PO")
#Due to too much data it is hard to read but as more games are played mor putouts occur. 
#Ones that are the top of the line would be the higher average players.<jupyter_output><empty_output><jupyter_text>Task 2 Analysis Pipeling  Graph 1 Parks around the world<jupyter_code>parks1_clean = (parks1
                .dropna(axis=0)
                .sort_values(by = "city", ascending = True)
               )
parks1_clean.head()
parks2_clean = (parks1_clean
                .drop(["park.key"], axis = 1)
                .dropna(axis = 0)
               )
parks2_clean.columns
parks3_clean = parks2_clean.rename({'park.name': "Park Name", 'park.alias': "Park Alias", 'city': "City", 'state': "State", 'country': "Country"}, axis = 1).reset_index().drop(['index'], axis = 1)
parks3_clean.head()
parks4_clean = (parks3_clean
                   .drop(["Country"], axis = 1)
                  )
parks4_clean.describe()
parks4_clean["State"].value_counts()
labels = ['OH', 'CA', 'IL', 'NY', 'PA', 'MA', 'MO', 'MI', 'IN', 'TX', 'QC', 'MD', 'IA', 'FL', 'CT', 'AZ', 'WA', 'ON', 'DC']
final_df = parks4_clean.loc[parks4_clean['State'].isin(['OH', 'CA', 'IL', 'NY', 'PA', 'MA', 'MO', 'MI', 'IN', 'TX', 'QC', 'MD', 'IA', 'FL', 'CT', 'AZ', 'WA', 'ON', 'DC']
)]
final_df.head()<jupyter_output><empty_output><jupyter_text>find a way to make a histogram graph of how many stadiums are in each state. Shows where watching baseball is more popular.<jupyter_code>plt.style.use('tableau-colorblind10')
fig = plt.figure(figsize=(11,11))
plt.pie(list(final_df['State'].value_counts()), autopct='%1.1f%%',labels = labels, wedgeprops={'edgecolor':'black'})
plt.title('Parks located around the World used in the MLB')
plt.tight_layout()
plt.show()<jupyter_output><empty_output><jupyter_text>Graph 2 Players with the most games played Fielding from 2000 ><jupyter_code>fielding1_clean = (fielding1
                .sort_values(by = "G", ascending = False)
               )
fielding1_clean
recentfielding_clean = fielding1_clean[fielding1_clean["yearID"] > 1999]
recentfielding_clean.head()
fielding2_clean = (recentfielding_clean
                   .drop(["stint", "WP", "GS", "ZR", "lgID", "E", "DP", "InnOuts", "PO", "A", "PB", "SB", "CS", "yearID", "POS"], axis = 1)
                  )
fielding3_clean = fielding2_clean.rename({'playerID': "Player ID", 'yearID': "Year", 'teamID': "Team", 'G': "Games Played"}, axis = 1).reset_index().drop(['index'], axis = 1)
fielding3_clean.head()
fielding4_clean = (fielding3_clean.dropna(axis = 0))
fielding5_clean = fielding4_clean[fielding4_clean["Games Played"] > 150]
fielding5_clean
fielding5_clean.describe()
fielding5_clean['Team'].value_counts()
labels = ['PHI', 'SEA', 'ATL', 'BAL', 'LAN', 'NYA', 'CHN', 'KCA', 'OAK', 'FLO', 'COL', 'TEX', 'MIL', 'CIN', 'ARI', 'SDN', 'HOU', 'TOR', 'CHA', 'DET', 'BOS', 'WAS', 'PIT', 'SLN', 'NYN', 'CLE', 'MON', 'SFN', 'ANA', 'LAA', 'MIA', 'TBA', 'MIN']
final2_df = fielding5_clean.loc[fielding5_clean['Team'].isin(['PHI', 'SEA', 'ATL', 'BAL', 'LAN', 'NYA', 'CHN', 'KCA', 'OAK', 'FLO', 'COL', 'TEX', 'MIL', 'CIN', 'ARI', 'SDN', 'HOU', 'TOR', 'CHA', 'DET', 'BOS', 'WAS', 'PIT', 'SLN', 'NYN', 'CLE', 'MON', 'SFN', 'ANA', 'LAA', 'MIA', 'TBA', 'MIN']
)]
plt.style.use('tableau-colorblind10')
fig = plt.figure(figsize=(11,11))
plt.pie(list(final2_df['Team'].value_counts()), autopct='%1.1f%%',labels = labels, wedgeprops={'edgecolor':'black'})
plt.title('What Teams in the MLB have the majority of Veteran players (>150 games played)')
plt.tight_layout()
plt.show()
#This graph shows which teams have the highest amounts of players that have played more than 150 games.<jupyter_output><empty_output><jupyter_text>Graph What Positions have the most Put Outs fielding Statistics from 2000 ><jupyter_code>fielding1 = pd.read_csv("../data/raw/fielding.csv")
fielding1.describe()
recentfielding_clean = fielding1[fielding1["yearID"] > 1999]
fielding1_clean = (recentfielding_clean
                .sort_values(by = "PO", ascending = False)
               )
fieldingSS_clean = (fielding1_clean
                   .drop(["stint", "SB", "teamID", 'yearID', "WP", "GS", "PB", "WP", "SB", "CS", "ZR", "A", "E", "DP", "InnOuts", "G", "lgID"], axis = 1)
                  )
fieldingSS_clean.head()
fieldingSS2_clean = fieldingSS_clean.rename({'playerID': "Player ID", 'yearID': "Year", 'lgID': "League", 'G': "Games Played"}, axis = 1).reset_index().drop(['index'], axis = 1)
fielding9_clean = fieldingSS2_clean[fieldingSS2_clean["PO"] > 0]
fielding9_clean.describe()
#Graph showing what positions have the most put outs from 2000 > 
sns.scatterplot(data = fielding9_clean, x = "POS", y = "PO")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1596244131455399, 'fraction_numerical': 0.018641259320629662, 'mean_word_length': 4.703149606299212, 'pattern_counts': {'":': 0, '<': 42, '<?xml version=': 0, '>': 50, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '242066', 'license': 'MIT', 'n_tokens_mistral': 2632, 'n_tokens_neox': 2493, 'n_words': 705, 'path': 'notebooks/analysis2.ipynb', 'repo_name': 'data301-2021-winter1/project-group37-project', 'size': '7244'}