Google colab is a cloud-based Python notebook. We’re planning to use this so that you don’t have to worry about installing software on your computer.
Go to colab.research.google.com
. You can use your private google account or you can activate your UIUC one here. If you can’t get to Google where you are, please let us know.
If a package is not installed, you can install it by doing:
!pip install [packagename]
You can grab data
import pandas as pd
df = pd.read_csv("https://covidtracking.com/api/v1/states/daily.csv")
def convert_to_datetime(x):
return str(x)[0:4]+'-'+str(x)[4:6] + '-'+str(x)[6:]
df['date_conv'] = pd.to_datetime([convert_to_datetime(x) for x in df['date']])
df_il = df[df['state']=='X']
import matplotlib.pyplot as plt
plt.plot('x','y',data=df_il)
df_il
Hit the +Text
button, which creates a markdown cell. Markdown is a simple language which translates human-readable text into pretty HTML. You can use LaTeX to write math; for example
$x^2$
You’ll need these libraries
import numpy as np
import matplotlib.pyplot as plt
Then, to plot
x = np.linspace(0,5,300)
y = x**2
plt.plot(x,y)
plt.xlabel("x")
plt.ylabel("y")
plt.xlim(0,4) # zoom in
pass #this just prevents an ugly printout
In this exercise, we will plot the total positive test results as function of time.
Sometimes the PDF export is a little fiddly. I notice that it works best in Chrome or Firefox.
sin(x)
and x
.sin(x)
and x
diverge; you’ll want to choose your x and y limits appropriately.sin(x)
.x
at the point of divergence.