Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Scatter Plot Part 1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Scatter Plot Part 2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
64 changes: 64 additions & 0 deletions answer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# -*- coding: utf-8 -*-
"""
Created on Thu Nov 8 09:50:51 2018

@author: Annaliese
"""

# Exercise 9

# import packages
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from plotnine import *

##############################################

# Part One

# define file name
file = "season.data.csv"

# read the csv file in
data = pd.read_csv("season.data.csv")

# produce a scatterplot
data.columns.values
x = data.loc[:,'tech.score']
y = data.loc[:, 'comp.score']

# calculate trend line
z = np.polyfit(x, y, 1)
p = np.poly1d(z)

# plot
plt.scatter(x, y)
plt.xlabel("Technical Score")
plt.ylabel("Component Score")
plt.title("Component Score vs. Technical Score for the 2017-2018 Figure Skating Grand Prix Season")
plt.plot(x, p(x), "r--")

# I included this data inthe assignment submission for reproducibility

#########################################################

# get new data
data = pd.read_csv("data.txt")

# calculate the means by each region
means = data.groupby('region')['observations'].mean()

# make a bar plot
means.plot(kind = "bar")

# make scatter plot
base = ggplot(data, aes(x = "region", y = "observations"))
base + geom_point() + geom_jitter() + theme_classic()

# The two plots show very different information. The bar plot shows that all
# of the means are very close together, but the scatterplot reveals
# that the spread of the data varies with the region. The West and East
# regions have large variability in their observations, whereas North has
# very little variation. The south region has two modes for its observations,
# which is very different from the others.
Binary file added bar plor part 2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions season.data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
competition,segment,discipline,placement,skater,country,tech.score,comp.score,skating.skills,transitions,performance,composition,interpretation,is.judge,component.range
russia,short,ladies,5,radionova.elena,russia,34.21,34.54,8.5,8.43,8.71,8.75,8.79,yes,0.36
russia,short,ladies,6,tursynbaeva.elizabet,kazakhstan,32.71,31.21,7.75,7.68,7.86,7.86,7.86,yes,0.18
russia,short,ladies,1,medvedeva.evgenia,russia,42.69,38.06,9.36,9.43,9.64,9.54,9.61,yes,0.28
russia,free,ladies,3,higuchi.wakaba,japan,69.37,68.2,8.5,8.36,8.61,8.61,8.54,no,0.25
russia,free,ladies,6,bell.mariah,america,64.37,60.34,7.61,7.25,7.71,7.57,7.57,yes,0.46
russia,free,ladies,12,mete.mae.berenice,france,53.65,53.07,6.57,6.32,6.82,6.71,6.75,no,0.5
canada,short,ladies,4,hicks.courtney,america,35.38,26.68,7.21,6.89,7.18,7.25,7.32,yes,0.43
canada,short,ladies,7,wagner.ashley,america,28.1,33.47,8.18,8.18,8.39,8.43,8.68,yes,0.5
canada,short,ladies,11,chartrand.alaine,canada,21.34,26.17,6.75,6.46,6.11,6.71,6.68,yes,0.64
canada,free,ladies,1,osmond.kaetlyn,canada,65.95,71.9,8.96,8.82,8.86,9.11,9.18,yes,0.36
canada,free,ladies,2,sotskova.maria,russia,61.34,65.08,7.96,7.89,8.29,8.25,8.29,yes,0.4
canada,free,ladies,10,pogorilaya.anna,russia,35.86,54.98,7.29,7,6.21,7,6.86,yes,1.08
china,short,ladies,4,zagitova.alina,russia,39.01,31.43,7.82,7.71,7.71,8.11,7.93,yes,0.4
china,short,ladies,8,li.xiangning,china,32.95,26.25,6.68,6.18,6.75,6.64,6.57,yes,0.57
china,short,ladies,9,choi.dabin,korea,26.1,27.8,7.04,6.71,6.89,7.07,7.04,yes,0.36
china,free,ladies,3,mihara.mai,japan,74.45,64.72,8.14,7.79,8.32,8.07,8.14,yes,0.53
china,free,ladies,10,glenn.amber,america,45.66,53.87,6.89,6.64,6.46,6.86,6.82,yes,0.43
china,free,ladies,11,zhao.ziquan,china,48.75,46.57,6.04,5.39,5.93,5.96,5.79,yes,0.65
japan,short,ladies,5,nagasu.mirai,america,34.45,30.72,7.82,7.29,7.82,7.68,7.79,yes,0.53
japan,short,ladies,10,rajicova.nicole,slovakia,27.33,27.03,6.82,6.57,6.64,6.86,6.89,yes,0.32
japan,short,ladies,6,miyahara.satoko,japan,31.02,34.03,8.5,8.29,8.54,8.5,8.71,yes,0.42
japan,free,ladies,8,shiraiwa.yuna,japan,55.29,59.31,7.61,7.14,7.57,7.39,7.36,yes,0.47
japan,free,ladies,12,park.soyoun,korea,35.19,50.06,6.5,6.21,6.11,6.25,6.21,yes,0.39
japan,free,ladies,3,kostner.carolina,italy,62.96,75.71,9.39,9.39,9.36,9.5,9.68,yes,0.32
france,short,ladies,4,mihara.mai,japan,31.93,32.64,8.29,7.82,8.11,8.21,8.36,yes,0.54
france,short,ladies,5,zagitova.alina,russia,32.27,31.19,7.89,7.68,7.57,7.89,7.96,yes,0.39
france,short,ladies,7,lecavelier.laurine,france,31.21,29.47,7.36,7.07,7.46,7.36,7.57,yes,0.5
france,free,ladies,4,osmond.kaetlyn,canada,68.42,70.3,8.86,8.57,8.68,8.86,8.96,yes,0.39
france,free,ladies,5,mihara.mai,japan,73.45,64.1,8.14,7.64,8.25,8,8.04,yes,0.61
france,free,ladies,6,shiraiwa.yuna,japan,64.86,63.27,7.93,7.61,8.04,8,7.96,yes,0.43
america,short,ladies,6,wagner.ashley,america,30.44,33.68,8.18,8.14,8.61,8.5,8.68,yes,0.54
america,short,ladies,8,tsurskaya.polina,russia,33.31,30.89,7.82,7.5,7.64,7.86,7.79,yes,0.36
america,short,ladies,9,chen.karen,america,29.6,30.93,7.71,7.5,7.64,7.89,7.93,yes,0.43
america,free,ladies,1,miyahara.satoko,japan,72.23,71.08,8.79,8.57,9.04,8.96,9.07,yes,0.5
america,free,ladies,2,sakamoto.kaori,japan,73.71,67.48,8.39,8.14,8.5,8.54,8.61,yes,0.47
america,free,ladies,3,tennell.bradie,america,72.68,64.41,7.86,7.71,8.36,8.07,8.25,yes,0.65