<jupyter_start><jupyter_text>fast5_melbourneScore and shot attempt analysis per player for the 2018 Fast5 World Series in Melbourne.  The top 5 scorers are: 1. <NAME> (ENG, 112 pts) 2. <NAME> (JAM, 89 pts) 3. <NAME> (AUS, 88 pts) 4. <NAME> (ZAF, 87 pts) 5. <NAME> (ZAF, 85 pts) Also of note is <NAME> (JAM) who scored 68 points from 52 shot attempts, the highest points/shot ratio.<jupyter_code>import sys
import pandas as pd

print('Python version: ', sys.version)
print('pandas version: ', pd.__version__)<jupyter_output>Python version:  3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)]
pandas version:  0.23.4<jupyter_text>Load the data showing goal attempts and scored for each player.  Data extracted from http://fast5worldseries.com.au/ .<jupyter_code>with open('fast5_melbourne_all.csv','r') as csvfile:
    df = pd.read_csv(csvfile, sep=',')
# Add some more in-depth stats
df['shots scored'] = df['G1']+df['G2']+df['G3']

df['points scored'] = df['G1'] + 2*df['G2'] + 3*df['G3']

df['shot attempts'] = df['G1A']+df['G2A']+df['G3A']

df['shot accuracy'] = df['shots scored']*100.0/df['shot attempts']

df['G1 accuracy'] = df['G1']*100.0/df['G1A']
df['G2 accuracy'] = df['G2']*100.0/df['G2A']
df['G3 accuracy'] = df['G3']*100.0/df['G3A']
# Show the data from all shots
df.sort_values(['points scored', 'shot attempts'], ascending=False).head(23)<jupyter_output><empty_output><jupyter_text>Load and analyse the data showing the breakdown of all scores from the matches, including any power play bonuses.  Data extracted from https://mc.championdata.com/fast5worldseries/ .<jupyter_code>with open('R1_2.csv','r') as csvfile:
    df2 = pd.read_csv(csvfile, sep=',')
    
# Example of the data
df2
# Compile all rows into a table (equivalent to a sum-if)
players = df2['Player'].unique()
actions = df2['Action'].unique()

df3 = pd.DataFrame(players, columns=['player'])
for act in actions:
    df3[act] = 0
    
df3 = df3.set_index('player')

for player in players:
    for action in actions:
        df3.loc[player, action] = len(df2.loc[(df2["Player"]==player) & (df2["Action"]==action)])
# Show the extracted data
df3
# Add additional statistics, as per the above data df
df3['G1'] = df3['1PT GOAL'] + df3['1PT GOAL (PP)']
df3['G2'] = df3['2PT GOAL'] + df3['2PT GOAL (PP)']
df3['G3'] = df3['3PT GOAL'] + df3['3PT GOAL (PP)']

df3['G1A'] = df3['G1'] + df3['1PT MISS']
df3['G2A'] = df3['G2'] + df3['2PT MISS']
df3['G3A'] = df3['G3'] + df3['3PT MISS']

df3['shots scored'] = df3['G1'] + df3['G2'] + df3['G3']
df3['shot attempts'] = df3['G1A'] + df3['G2A'] + df3['G3A']

df3['points (ignore PP)'] = df3['G1'] + 2*df3['G2'] + 3*df3['G3']

df3['points'] = (1*df3['1PT GOAL'] + 2*df3['1PT GOAL (PP)']
                 + 2*df3['2PT GOAL'] + 4*df3['2PT GOAL (PP)']
                 + 3*df3['3PT GOAL'] + 6*df3['3PT GOAL (PP)'])

df3['points per shot'] = df3['points']/df3['shot attempts']<jupyter_output><empty_output><jupyter_text>Results of analysis<jupyter_code># Show some of the key statistics
df3[['G1', 'G2', 'G3', 'G1A', 'G2A', 'G3A', 'shot attempts',
     'points (ignore PP)', 'points', 'points per shot']].sort_values('points', ascending=False)
# For comparison, show the table from the original data (without the power play points)
df[['name', 'G1', 'G2', 'G3', 'G1A', 'G2A', 'G3A', 'Country', 'shots scored',
    'shot attempts', 'points scored']].sort_values(
    ['points scored', 'shot attempts'], ascending=False).head(23)
#df.sort_values(['points scored', 'shot attempts'], ascending=False).head(23)<jupyter_output><empty_output><jupyter_text>As a quick sanity check, we show that the sorted points and shot attempts represent the same information.<jupyter_code>(list(df.sort_values(['points scored', 'shot attempts'], ascending=False).head(23)['shot attempts']) ==
 list(df3.sort_values(['points (ignore PP)', 'shot attempts'], ascending=False)['shot attempts']))
(list(df.sort_values(['points scored', 'shot attempts'], ascending=False).head(23)['points scored']) ==
 list(df3.sort_values(['points (ignore PP)', 'shot attempts'], ascending=False)['points (ignore PP)']))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19344736208142616, 'fraction_numerical': 0.05179474825343291, 'mean_word_length': 5.559241706161138, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 26, 'https://': 1, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '117612', 'license': 'MIT', 'n_tokens_mistral': 1640, 'n_tokens_neox': 1551, 'n_words': 410, 'path': 'fast5_melbourne.ipynb', 'repo_name': 'stephenpcook/fast5_2018', 'size': '4197'}