Break Through!!!!!

Ciana Eison

I was very lucky to have a fellow classmate (Andrew) come up and help me with my code. He had also done a scatterplot, which allowed his file to be read. My biggest issue was that I had to manually put in all of my data points. After comparing my code to andrew's I leanred that I had 2 issues with my code. The first was code that was wrong was "na_value=None". This code is suppose to dismiss missing values in the data set and becuase I have spaces thorugout my data set for organization purposes, I thought I would have to use the na_value = None to dimiss the missing values. However, I was wrong and didnt know that Python will automatically overlook these missing values or blank spots. My second problem was how i listed my x and y coordinates. Its true that the data i gave read the coordiantes, but i had to put them in manually. When I tried to code python to read the columns of my graph I began with x = and y = . I also failed to use the function 'data' in my x and y coordinates. The function 'data' allows a string or array of numbers or data to be collected and used in the code/graph. Now I am very happy to say I know how to code a scatterplot by having it read the file. Above you can see the difference in code.

Tuesday 10:15pm: Arduous Process

Ciana Eison

So, after doing more research on how to read a file in excel, I have sadly come up empty handed. The good thing is, I know how to code a scatter plot. The bad news is: I don’t know how to make python read the file. My final code is listed below. As you can see I have color coded dots to represent different seasons (Pre vs. In vs. Post vs the totals season sports). I did this to learn how to make the graph more visually appealing and easier to read when comparing data. In the future I hope to continue to work on this graph, as I will be using something very similar for my research and senior Project. Therefore, I will continue to search for the solution.


 

Below is the code:

 

"""

Simple demo of a scatter plot.

"""

#the 3 lines below are libraries that hold information

import numpy as np      #np reads the numeric data

import matplotlib.pyplot as plt #plt is a library

import pandas as pd  #pd allows you to read the file

#this code is suppose to read the file

data = pd.read_csv("Game Injury Rate.csv", low_memory=False, na_values = None)

 

#Label allows you to give a title or label

plt.xlabel('Practice Injury Rate per 1000 Athlete Exposure')

plt.ylabel('Game Injury Rate per 1000 Athlete Exposure')

plt.title ('Game vs.Practice')

 

#below is the numeric data for the x and y coordinates

x = (7.28,2.40,1.59,4.27, 6.42,2.23,1.23,3.93, 5.87,2.31,1.06,3.62)

y = (7.01,16.24,9.47,15.47, 6.29,13.61,8.48,13.03, 4.86,13.08,7.92,12.36)

 

#color for pre-season

plt.scatter (7.28,7.01,color = 'r')

plt.scatter (6.42,6.29,color = 'r')

plt.scatter (5.87,4.86,color = 'r')

 

#Color for In-season

plt.scatter (2.40,16.24,color = 'm')

plt.scatter (2.23,13.61,color = 'm')

plt.scatter (2.31,13.08,color = 'm')

 

#color for post-season

plt.scatter (1.59,9.47,color = 'g')

plt.scatter (1.23,8.48,color = 'g')

plt.scatter (1.06,7.92,color = 'g')

 

#color for total division

plt.scatter (4.27,15.47,color = 'y')

plt.scatter (3.93,13.03,color = 'y')

plt.scatter (3.62,12.36,color = 'y')

plt.show()

 

Tuesday 8:40: Getting concerned

Ciana Eison

    The graph below, is what the graph should look like. However, it’s done manually and not by reading the file. When I say, manually, I mean i had to put in my x and y coordinates. However, python should be able to read my coordinates automatically from the csv file. This is opposing as a big challenge. I have looked up several different websites, youtube videos, and tutorials on how to allow Python to read the file, but all of the codes are listing their x and y coordinates.

 

Different function I tried include: .xlrd, .np..

Sources: StackOverflow, Youtube tutorials, matplotlib

 

Tuesday: 7:40

Ciana Eison

I have successfully learned how to label the graph and give it a title, but I’m still having trouble figuring out how to tell python to read the file. I can create a scatterplot if i manually put in the x and y data, but I’d much rather have it by reading the file. My goal from now on is to figure out, how to make python to read the file.

 

Just in case you can’t read the code above:

# -*- coding: utf-8 -*-

"""

Created on Mon Sep 19 10:30:04 2016

 

@author: cianaeison

"""

 

"""

Simple demo of a scatter plot.

"""

import numpy as np

import matplotlib.pyplot as plt

import pandas as pd

#this code allows you to read the Russia file and call it 'data'

#so that you will be able to access the file easier

data = pd.read_csv("Game Injury Rate.csv", low_memory=False, na_values = None)

plt.xlabel('Practice Injury Rate per 1000 Athlete Exposure')

plt.ylabel('Game Injury Rate per 1000 Athlete Exposure')

 

x = (1,2,3,4,5)

y = (6,7,8,9,10)

plt.scatter (x,y, color = 'k')

plt.title ('Practice vs. Game')

plt.show()

Tuesday: 6ish o’clock

Ciana Eison

I began working on the code again. First I created the excel file with all the correct data. Next I began working with the code. The data I found consists of two variables about the injury rate per 1000 person athlete exposure. One variable is from the athletes games while the other is from the practices. The other is the injury rate per 1000 person athlete exposure during games.

Tuesday (Sep.20, 2016)

Ciana Eison

Around 10:00am

I had the sliver of time in which i decided to work on my project. While working on it for roughly 5 min, I was able to create a scatterplot. It was very basic, but it included all of the information. My only problem was, I had to physically list the x and y axis numerical data. Instead i wanted Python to read the file and do it for me. So the next step was learning how to code python to read the file. This project was put on hold after watching DP’s tutorial on One-analysis statistics. I realized after the class, that I was using one variable instead of a two variables. Therefore, my coding was put on hold to find two variables that would coincide with my project. Luckily, I found a set of raw data on an academic source which was available to use. After getting it approved by DP (to make sure it was ok to use other people’s data), my next goal was to put it into an excel file.

Monday (Sep. 19, 2016):

Ciana Eison

Today I started by trying to copy the axis from the bar graph and making the into my own graph as a start. That idea failed. I later discovered that I was missing an important part of the code which started the whole process. What I was missing was this:

 

Functions

# pandas, numpy, and matplotlib.pyplot are libraries (add-ons)

import pandas

import numpy as np

import matplotlib.pyplot as plt



 

This piece of the code, belongs in the beginning of the code before you start to tell python what you want it to do. What this code is a command style function allows changes to be made within the graph.

 

After this great realization, I decided to resort back to google to search for way to create the scatter plot. I found a website called, matplotlib.org, which gives a basis of how to create the scatterplot.

 

After working on coding for about an hour and a half, I have created my excel files for the numbers I will be using. I have also found a credible website to aid me in creating the scatterplot and to help define what the functions are and what they do. Below is a picture of the code I have developed so far.



My next challenge is to define what the code means and how the numbers are used within the data. I also do not know what the N= means, and what the area and second to last line mean. SO the next step in my plan is to define, discover, learn, and document.

Sunday (Sep. 18, 2016):

Ciana Eison

I began research on how to create the scatterplot on google. I began by studying the bar graph, DP gave us. My original thought was that I could study this graph, and use the same code to create my axis. (because both the bar and scatterplot have an x and y axis). After reading and making an attempt to understand the code, I became confused. This lead me to my search on google, which lead me to several websites, each with a different way to code. My big problem was understanding what the code was saying.