<jupyter_start><jupyter_text>Lambda School Data Science - Making Data-backed AssertionsThis is, for many, the main point of data science - to create and support reasoned arguments based on evidence. It's not a topic to master in a day, but it is worth some focused time thinking about and structuring your approach to it.  Assignment - what's going on here?Consider the data in `persons.csv` (already prepared for you, in the repo for the week). It has four columns - a unique id, followed by age (in years), weight (in lbs), and exercise time (in minutes/week) of 1200 (hypothetical) people.Try to figure out which variables are possibly related to each other, and which may be confounding relationships.Try and isolate the main relationships and then communicate them using crosstabs and graphs. Share any cool graphs that you make with the rest of the class in Slack!<jupyter_code># import the persons.csv and save it in a variable called person_url
person_url = 'https://raw.githubusercontent.com/cardstud/DS-Unit-1-Sprint-1-Dealing-With-Data/master/module3-databackedassertions/persons.csv'
# save the file using !wget
!wget 'https://raw.githubusercontent.com/cardstud/DS-Unit-1-Sprint-1-Dealing-With-Data/master/module3-databackedassertions/persons.csv'
!ls
# import pandas library and save persons.csv as a dataframe
import pandas as pd
persons = pd.read_csv('persons.csv')
# Take a quick glance at the columns, index and data
persons.head()
# Checking all rows, minus the first column which was unnamed
persons.iloc[:, [1,2,3]]
# Do a crosstab between age and weight variables
pd.crosstab(persons['age'], persons['weight'])
# bug in 0.24.2 pandas so installed pandas 0.23.4
!pip install pandas==0.23.4
# Cut the age feature into bins to make it easier to look at
persons_bins = pd.cut(persons['age'], 5)
# Did a crosstab and normalize the values
pd.crosstab(persons['weight'], persons_bins, normalize='columns')
# Cut age feature into bins and looked at a crosstab between age and exercise_time variables
persons_bins = pd.cut(persons['age'], 5)
pd.crosstab(persons['exercise_time'], persons_bins)
# Cut the weight variable into bins and did a crosstab between weight and exercise_time variables
persons_bins = pd.cut(persons['weight'], 5)
pd.crosstab(persons['exercise_time'], persons_bins)
# imported matplotlib and did a scatter plot for weight as a function of Exercise Time
import matplotlib.pyplot as plt
weight_p = plt.scatter(persons['exercise_time'], persons['weight'], color = 'blue')
plt.title('Exercise Time vs Weight')
plt.xlabel('Exercise Time')
plt.ylabel('Weight')
# Did a scatterplot of Weight as a function of Age
age_p = plt.scatter(persons['age'], persons['weight'], color = 'blue')
plt.title('Age vs Weight')
plt.xlabel('Age')
plt.ylabel('Weight')
# Did a scatterplot of Exercise Time as a function of age
exercise_p= plt.scatter(persons['age'], persons['exercise_time'], color = 'blue')
plt.title('Age vs Exercise Time')
plt.xlabel('Age')
plt.ylabel('Exercise Time')<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup