<jupyter_start><jupyter_text>Baseball Statistics: Salaries Baseball is a game full of statistics, and most of those statistics have been consistently and carefully tracked going back to the late 1800s. That makes professional baseball a playground for data analysts. Here I look at interesting correlations between players, their stats, and their salaries.**Data Source:** [Lahman's Baseball Database](http://www.seanlahman.com/baseball-archive/statistics/). The data set I used was through the 2018 season.Copyright © 2019 <NAME> (<EMAIL>)<jupyter_code>%run ./1_Data_Preparation.ipynb
plt.style.use(['default', 'fivethirtyeight', 'seaborn-poster'])<jupyter_output><empty_output><jupyter_text>I want to use inflation-adjusted salary figures, so I obtained CPI data from the Bureau of Labor Statistics. Salary data only goes back to 1985, so I got annual figures for 1985-2018.<jupyter_code>salaries.head()
inflation = pd.read_csv('data/CPI.csv')
inflation.head()
# Add a CPI Multiplier column based on the last row in the CPI dataframe, 2018.
# Technique from here: https://towardsdatascience.com/adjusting-prices-for-inflation-in-pandas-daaaa782cd89
inflation['CPI_Multiplier'] = inflation['CPI'].iloc[-1] / inflation['CPI']
inflation.tail()
inflation[inflation['Year'] == 2006]['CPI']
salaries = pd.merge(salaries, inflation, how='left', left_on='yearID', right_on='Year')
salaries.head()
salaries.tail()
salaries['salary_2018$'] = salaries['salary'] * salaries['CPI_Multiplier']
salaries.head()
ax = sns.boxplot(x='yearID', y='salary_2018$', data=salaries)
plt.setp(ax.get_xticklabels(), rotation=45)
plt.show()
ax = sns.boxplot(x='yearID', y='salary_2018$', data=salaries)
plt.setp(ax.get_xticklabels(), rotation=45)
ax.set_yscale('log')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.132996632996633, 'fraction_numerical': 0.030864197530864196, 'mean_word_length': 6.959821428571429, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '35126', 'license': 'MIT', 'n_tokens_mistral': 638, 'n_tokens_neox': 576, 'n_words': 157, 'path': '6_Salaries.ipynb', 'repo_name': 'Uvacoder/baseball-statistics', 'size': '1800'}