<jupyter_start><jupyter_text>SetupThis demonstration notebook provides a suggested set of libraries that you might find useful in crafting your data stories.  You should comment out or delete libraries that you don't use in your analysis.<jupyter_code>#number crunching
import numpy as np
import pandas as pd

#data visualization
import seaborn as sns<jupyter_output>/usr/local/lib/python3.6/dist-packages/statsmodels/tools/_testing.py:19: FutureWarning: pandas.util.testing is deprecated. Use the functions in the public API at pandas.testing instead.
  import pandas.util.testing as tm<jupyter_text>Project team<NAME> and <NAME> Background and overviewOur motivation was due to the fact that we are both golf enthusiasts and were interested in how data can show itself in the sport in a similair fashion to that which we saw with money ball. ApproachWe will be considering the correlation between tournament money one by players and various metrics relating to their drive distance from the tee.  Quick summaryWe saw that there was a positive correlation between average drive dstance and tournament money won and converesely a negative correlation between distance to tee after first drive and tournament money won.  DataBriefly describe your dataset(s), including links to original sources.  Provide any relevant background information specific to your data sources.<jupyter_code># Provide code for downloading or importing your data here
# Load CSV file data into a dataframe.
# We put the data on my local github for ease of upload:
dataset = pd.read_csv('https://raw.githubusercontent.com/scottstuart11/strokes-gained/master/Final_Data.csv')
dataset<jupyter_output><empty_output><jupyter_text>AnalysisBriefly describe each step of your analysis, followed by the code implementing that part of the analysis and/or producing the relevant figures.  (Copy this text block and the following code block as many times as are needed.)<jupyter_code># Transpose the data so that the rows relating to features are their own columns (those features being Distance to hole, Averade Drive Distance, and Money) now have their own columns 
df = dataset.set_index(['Player Name', 'Variable', 'Season'])['Value'].unstack('Variable').reset_index()

df.rename(columns = {'Total Money (Official and Unofficial) - (MONEY)':'Money (Millions)', 'Average Distance to Hole After Tee Shot - (AVG)':'Distance to Hole (Yards)', 'Total Distance Efficiency - (AVERAGE DISTANCE (YARDS))':'Average Drive Distance (Yards)'}, inplace = True)

df.head()

# Gets rid of commas and dollar signs in the money values so they can then be made into numbers 
# for graph presentation
def remove_and_convert(chars_to_remove, feature, df):
  for feat in df.columns[2:]: # for each feature
    if(feat == feature):        # if it matches with the variable feature (money)
      for char in chars_to_remove:   # for each of the characters to remove
        df[feature] = df[feature].str.replace(char, '') #replace the character with nothing
    df[feat] = df[feat].astype(float) # turn the values into floats
  return df

df = remove_and_convert(["$", ","], "Money (Millions)", df)

df.head()
# https://seaborn.pydata.org/generated/seaborn.regplot.html
# Each dot is a player-season, initially was using reg plot with the line below:
# sns.regplot(x="Average Drive Distance", y="Money", data=df, color = 'Green')

# But found this one on stack overflow: https://stackoverflow.com/questions/31568874/how-to-change-the-line-color-in-seaborn-linear-regression-jointplot

g = sns.jointplot(x="Average Drive Distance (Yards)", y="Money (Millions)", data=df, kind='reg',joint_kws={'line_kws':{'color':'cyan'}})
# plt.ticklabel_format(style='plain', axis='both', useOffset=False)

g = sns.jointplot(x="Distance to Hole (Yards)", y="Money (Millions)", data=df, kind='reg', joint_kws={'line_kws':{'color':'cyan'}})
# sns.boxplot(x="Season", y="Average Drive Distance", data=df);<jupyter_output><empty_output><jupyter_text>Interpretations and conclusionsAccording to strokes gained, distance and accuracy of the drive is the biggest predictor of success for a golfer which is what our data showed as well. Future directionsCould consider short game metrics such as chipping and putting and see how performance here predicts succcess in tournaments.<jupyter_code><jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09028097650852142, 'fraction_numerical': 0.003454629203132197, 'mean_word_length': 5.530827067669173, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '334492', 'license': 'MIT', 'n_tokens_mistral': 1237, 'n_tokens_neox': 1174, 'n_words': 497, 'path': 'data-stories/strokes-gained/strokes_gained.ipynb', 'repo_name': 'BohanMeng/storytelling-with-data', 'size': '4359'}