<jupyter_start><jupyter_text>The Prevalence of Concussion in Amateur Irish Rugby Players![concussion](img/concussion1.jpg)  IntroductionI have decided to base my assigment on a collection of data I gathered for my thesis as part of my Bsc. in Physiotherapy in 2012. For my thesis I investigated the overall prevalence of concussion in Irish amateur rugby players. On completion of my research my findings were used in various different sports medicine conferences and also featured in a national newspaper at the time. Concussion is defined as a “complex pathophysiological process affecting the brain, induced by traumatic biomechanical forces”(3). There are over 150,000 registered rugby players in Ireland and despite the popularity of the game, the physical nature of rugby can lead to many injuries occurring like concussion(5). The mismanagement of repeated concussion can lead to very serious long term effects like amnesia and brain damage(6). Ireland has also experienced an increased exposure to the long term effects of concussion following the premature retirement of International rugby players due to their mismanagement of multiple concussions (7).Concern regarding concussion injury in rugby union has grown, due to its potentially dangerous long- term effects on players, but the prevalence is not known in Ireland(3). There are strict ‘return to play’ guidelines after concussion(4), however, it is unclear how compliant players are in regards to these regulations in Ireland. Previous studies of New Zealand rugby players have found the career prevalence of concussion to be as high as 60%(1). Hollis et al. in 2009 found that a player who received one concussion was twice as likely to suffer another later in the season (2). At the time of my study there was no published data on Irish rugby players. The original study consisted of 114 amatuer players who played with various Leinster junior rugby clubs. Each player filled out a questionnaire designed by myself to investigate how common concussion was, it's symptoms and how much each player knew about concussion. Below is a copy of the first 2 pages of the questionnaire that I created to collect the data. ![Q1](img/Q1.png)![Q2](img/Q2.png)Almost 33% (37/114) of players suffered a diagnosed concussion during their rugby-playing career (95% C.I. 23.4%-40.6%). Headache was the most common post-concussion symptom, present in 86% (32/37) of those with diagnosed concussion, dizziness ranked second ith 24% and nausea was third with 15%. Mean age of the 114 respondents was 25 years.The mean duration playing rugby was 13 years. Players trained 2 hours (median) a week and participated in 14 (median) matches a year. 46% concussions occurred in forwards and 54% in backs. 75% of players felt that concussion a danger to welfare however 57% would play in an important game if suffering from concussion symptoms.Below is the graph depicting the post concussion symtopms players reported in the original study. ![symptoms](img/symptoms.png)  Variables and their relationships I intend on using a few of the main points from the originl dataset for this projet. I am also going to try and find a hypothetical link between the more games a player plays after a concussion, the more likely he is to suffer a repeat injury. I found from my original dataset that 92% of concussions happen during a game. The most worrying statistic was that when a player suffered a concusion he generally had on average another 2 concussion after that original event. The 37 players who suffered a concussion from my original study accounted for 85 concussions between them with the average being 2.29 concussions per player. Nathonson et al in 2013 found the season prevalence of concussion in professional American Football players to be extremely high(8). They found that in 480 games, there were 292 concussions, resulting in 0.61 concussions per game. Applying this ratio to Irish amateur rugby, in theory the more games a player plays the increased risk of concussion and this is the hypothetical link I will try to find. I have decided to mock up the data of 100 players who suffered a concussion using the four variables of age, number of games played in a season, number of concussions and most common post-concussion symptom. I will use the first variable as a non zero integer (Age) with the normal distribution between 20-30 years. I have used the normal distribution for this variable as the mean age of players was 25 between with the range from 20-30 which should fit nicely into this distribution. My second variable will be a non zero integer (Games) and I will use the Gamma distribution between 10-20 games. My third variable will be a non zero integer (Concussion) which will again be with an Gamma distribution between 1-3. I have decided to use the Gamma distribution for both by second and third variables to try and create a graph indicating a relationship between the two variables. Ideally the graph will represent a linear relationship between the more games they play post concussion the more injuries are likely to occur. From the original study players who suffered a concussion generally suffered on average two more.  My last variable will be (Symptoms) which will be selected using normal distribution to divide up headache, dizziness and nausea. The first three variable will be non-zero integers and the last variable will be categorical variable with three different values. I have used normal distribution for these variables as generally each player would suffer from a multiple of different symtopms with these three conditions being the most prevalent.I will use this notebook to develop an algorithm to discuss my hypothetical link between an increased number of games post concussion leading to a heightened risk of suffering another concussion. I will generate some data using the numpy.random package and pandas and seaborn packages to analyse the data.  Generate the Concussion Data and Data Analysis  1. Age<jupyter_code># Age variable
# Import the libraries I will use to evaluate the age of the 100 players who suffered a concussion. 
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

#Make sure the graph is printed below
%matplotlib inline

# Using randint from the numpy.random package, variables based on my previous study
age = (np.random.randint(20,30,100,))
print (age)

# Created a database of just age
age = pd.Series(np.random.randint(20,30,100,))


# Format the histogram
age.plot.hist(grid=True, bins=10, rwidth=0.5,
                   color='#607c8e')
plt.title('Average Age of 100 Players with Concussion')
plt.xlabel('Years of age')
plt.ylabel('Number of Players')
plt.grid(axis='y', alpha=0.75)

# https://realpython.com/python-histograms/<jupyter_output>[27 24 25 23 25 21 25 26 21 28 27 22 28 20 29 22 25 22 25 29 29 23 28 26
 28 24 23 24 21 21 25 20 24 20 23 22 25 21 28 27 29 23 25 21 26 27 25 28
 28 22 26 29 21 28 29 28 24 22 22 29 21 24 26 23 26 22 26 26 26 21 23 27
 25 21 22 24 23 22 25 29 26 23 27 25 21 27 22 24 29 27 24 20 28 21 27 24
 23 25 25 26]<jupyter_text>2. Number of Concussion Per Player<jupyter_code>#Finding the average number of concussion per 100 Players
# Importing the necessary packages

import numpy as np 
import matplotlib.pyplot as plt
import pandas as pd
# Make sure that the graph is printed below
%matplotlib inline

# Created the variable, using the randint package from the numpy.random package.
# Values ranging to find the average number of concussions
concussion = np.random.randint(0,4,100,)

# print out the values
print (concussion)

# Created a database to develop and investigate the variables
concussion = pd.Series(np.random.randint(0,4,100,))

# Format the histogram
concussion.plot.hist(grid=True, bins=10, rwidth=1,
                   color='#607c8e')
plt.title('Average Age of 100 Players with Concussion')
plt.xlabel('Years of age')
plt.ylabel('Number of Players')
plt.grid(axis='y', alpha=.2)<jupyter_output>[1 2 3 0 3 3 0 2 3 2 3 3 0 0 0 1 1 2 3 0 1 2 3 0 3 3 1 2 3 2 3 2 2 2 0 3 1
 2 0 2 3 3 0 1 0 3 1 3 2 2 0 2 3 1 1 0 1 2 1 2 1 1 0 3 0 1 0 0 3 1 2 3 1 1
 3 0 0 2 0 1 2 2 0 2 0 1 2 3 3 2 1 1 2 2 2 2 3 2 3 1]<jupyter_text>3. Symptoms of Concussion<jupyter_code>#Symptoms of Concussion

#Import the packages required. 
import pandas as pd
import numpy as np

# Create the variale
symtopms= ['Headache', 'Dizziness','Nausea']

# Create the dataframe to use for analysis, random.choice package from the numpy.random library to 
s = pd.Series(np.random.choice(symtopms) for i in range (100))
print (s)


%matplotlib inline
# Generating the variables for the histogram table
symtopms = ['Dizziness', 'Headaches', 'Nausea']
# Took the values generated from the above dataframe
values =[40,35,25]

plt.figure(1, figsize=(9, 3))

# 3 different types of plots to show the variables
plt.subplot(131)
plt.bar(symtopms, values)
plt.subplot(132)
plt.scatter(symtopms, values)
plt.subplot(133)
plt.plot(symtopms, values)
plt.suptitle('Symtopms of Concussion')
plt.show()

#https://matplotlib.org/tutorials/introductory/pyplot.html#sphx-glr-tutorials-introductory-pyplot-py<jupyter_output>0     Dizziness
1      Headache
2     Dizziness
3     Dizziness
4      Headache
5        Nausea
6        Nausea
7      Headache
8      Headache
9     Dizziness
10     Headache
11     Headache
12     Headache
13     Headache
14    Dizziness
15       Nausea
16    Dizziness
17    Dizziness
18       Nausea
19       Nausea
20    Dizziness
21     Headache
22    Dizziness
23     Headache
24    Dizziness
25    Dizziness
26       Nausea
27    Dizziness
28    Dizziness
29     Headache
        ...    
70     Headache
71     Headache
72     Headache
73     Headache
74    Dizziness
75    Dizziness
76       Nausea
77    Dizziness
78       Nausea
79     Headache
80     Headache
81       Nausea
82    Dizziness
83    Dizziness
84     Headache
85     Headache
86     Headache
87    Dizziness
88       Nausea
89     Headache
90       Nausea
91       Nausea
92     Headache
93    Dizziness
94     Headache
95     Headache
96       Nausea
97    Dizziness
98     Headache
99       Nausea
Length: 100, dtype: obje[...]<jupyter_text>4. Number of games per Player<jupyter_code># Generating data for average number of games played in a season

import matplotlib.pyplot as plt
import scipy.special as sps
import numpy as np

shape, scale = 14, 1.  # mean=14, std=5
s = np.random.gamma(shape, scale,100)
count, bins, ignored = plt.hist(s, 15, density=True)
y = bins**(shape-1)*(np.exp(-bins/scale) / (sps.gamma(shape)*scale**shape))
plt.plot(bins, y, linewidth=2, color='r')
plt.xlabel('Number of games')
plt.ylabel('Number of players')
plt.show()

#https://docs.scipy.org/doc/numpy/reference/generated/numpy.random.gamma.html#numpy.random.gamma<jupyter_output><empty_output><jupyter_text>4B. Attempted to create a link between games and concussion<jupyter_code>import numpy as np
import pandas as pd
# Make sure that the graph is printed below
%matplotlib inline

# Created the variable, using the randint package from the numpy.random package.
# Values ranging to find the average number of concussions


shape, scale = 2, .5  # mean=4, std=2*sqrt(2)
c = np.random.gamma(shape, scale, 100)
print (c)
import matplotlib.pyplot as plt
import scipy.special as sps
count, bins, ignored = plt.hist(c, 4, density=True)
y = bins**(shape-1)*(np.exp(-bins/scale) /(sps.gamma(shape)*scale**shape))
plt.plot(bins, y, linewidth=1, color='r')
plt.xlabel('Number of concussions')
plt.ylabel('Number of players')
plt.show()
#https://docs.scipy.org/doc/numpy/reference/generated/numpy.random.gamma.html#numpy.random.gamma<jupyter_output>[0.45040904 5.37392886 2.69812549 1.30787476 1.21186103 2.14739815
 1.22081471 1.01977611 0.81069445 0.74659477 1.40513032 0.34318705
 1.97877845 1.79124812 0.20828607 1.28315747 0.52376492 0.15762268
 2.35680454 1.42248698 1.02409369 1.07325099 0.81194431 0.11167132
 1.45633377 0.37419186 1.17235798 0.349403   0.04977951 0.82038351
 0.20290251 0.04953532 0.6435158  1.71424178 0.42587843 0.48441016
 0.58751945 0.58489705 0.93583259 0.98868314 0.56907763 1.59220379
 1.22051684 1.33110753 0.79219255 1.12865793 0.59751332 0.17463431
 0.59436528 0.50233483 0.33467069 0.46102795 1.24698101 1.08256268
 0.49500347 1.16814837 0.74304255 1.39534959 2.07091991 0.22807353
 0.59254473 0.86152169 0.46802326 2.55177235 0.90709868 0.75837808
 0.31913838 0.90404617 1.41555803 1.6499884  2.02499141 2.03227465
 1.66114419 0.50288935 2.15234354 1.01233408 0.56252018 0.60378532
 0.92279996 1.16979141 0.47752963 0.32558506 1.34547463 1.60788072
 0.291255   0.35656912 0.36698888 0.59304544 0.94482873 0.0415[...]<jupyter_text>5. Creating the Dataframe with all the Variables<jupyter_code># I tried to create a dataframe with all of the variables grouped together. 
# Unfortunately I was unable to create successfully and was not able to access the data needed to do some data analysis on it
# I left this is to show my efforts at creating the dataframe and why I had to use individuals sections for the data analysis

import pandas as pd
import numpy as np

data = {'Age' :[np.random.randint(20,30,100,)], 'Concussion' :[np.random.randint(1,3,100,)], 'Games' :[np.random.randint(10,20,100,)]}
df = pd.Series(data,index=['player'])
df= pd.Series(data)

print (df)

df.describe()
#http://www.datasciencemadesimple.com/descriptive-summary-statistics-python-pandas/<jupyter_output>Age           [[23, 22, 29, 21, 23, 22, 26, 27, 27, 21, 23, ...
Concussion    [[1, 2, 2, 1, 1, 1, 2, 2, 2, 2, 1, 1, 2, 2, 2,...
Games         [[17, 13, 10, 12, 18, 13, 11, 12, 12, 15, 14, ...
dtype: object
{'fraction_non_alphanumeric': 0.0657287315893603, 'fraction_numerical': 0.11115996189638748, 'mean_word_length': 4.058561897702002, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 4, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 21, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '495475', 'license': 'Apache-2.0', 'n_tokens_mistral': 5275, 'n_tokens_neox': 4043, 'n_words': 1926, 'path': 'Real World Data.ipynb', 'repo_name': 'tullowhurler/Real-World-Data-', 'size': '13647'}