General assignment information#
Getting started#
To edit/execute a Homework/lecture notebook:
Open the page for the Homework/Lecture on this site.
For example: Homework 0
Click the launch button (🚀) at the top.
You should now see the notebook in Google Colab.
Make sure you’re using your Columbia Google account. How to switch.
Click
Copy to Drive
. That is now your own copy; make edits in there directly.
Open-ended assignments#
You’ll create your own notebook.
Tips#
Read the instructions carefully. Like word problems from math class, they are very specific in what they are asking for.
Ask for help.
The assignments are meant to be challenging, not impossible.
Try and work through problems on your own to start. If you are stuck for more than a half hour, step away. If you still can’t figure it out, ask for help.
Coding in general#
Make variable names descriptive.
Do as I say, not as I do!
Only do one thing per line.
Makes troubleshooting easier
Spot check your results. If you are transforming data from a previous Step, compare the results, do a handful of the calculations manually, etc. to ensure that the results are correct.
Don’t repeat yourself (DRY). If you find yourself copying and pasting code within your file(s), there’s probably a better way to do it.
Avoid hard-coding values. Don’t rely on things like row numbers or column order being stable, in case the dataset were to be updated.
Jupyter / Google Colab#
Keep each cell to only a few lines of code.
Allows/encourages you to output intermediate results, ensuring that everything is working as expected.
You are always welcome to add cells. You probably don’t want more than a few lines of code in each. This makes the spot checking of intermediate results easier.
Make notebooks idempotent
Makes your work reproducible.
Use
Restart and run all
(⏩ button in toolbar).
Submission#
Ensure all the outputs are visible and the notebook is cleaned up.
This is a good time to run the notebook end-to-end with
Restart and run all
.
Confirm that the notebook is shared with the instructor and Reader with
Commenter
permissions. If it isn’t, share the parent folder and re-confirm.Copy the URL of your notebook.
The URL should be of the format
https://colab.research.google.com/drive/<long identifier>
. If it’shttps://colab.research.google.com/github/...
, clickCopy to Drive
.
Paste your notebook URL in the CourseWorks Assignment.
Engaging with comments left in Google Colab is more than welcome.
Notes#
In-class exercises will not be submitted/graded.
Common issues#
Mounting Google Drive is slow or fails: See the Google Colab help page.
Can’t load a file from Drive with
requests.get()
: Useopen()
.When using
choropleth_map()
, nothing appears on the map: Make sure:Your
locations
corresponds to the DataFrame column name andfeatureidkey
is set toproperties.<property name>
matching the GeoJSONThe column and the GeoJSON properties have values that match
SettingWithCopyWarning
: How to fixinput()
stuck: Jupyter can be a bit buggy when dealing with interactive input. If it seems to get stuck or you aren’t seeing a prompt when you’d expect one, try clicking theRuntime
menu thenRestart Kernel
.The values are out of order along the axis of a Plotly chart: Make sure that:
The values are integers/floats/timestamps, not strings, where applicable.
AttributeError: partially initialized module 'orjson' has no attribute 'OPT_NON_STR_KEYS'
: Add the following cell before your other Plotly code, thenRestart and run all
.import plotly.io plotly.io.json.config.default_engine = 'json'
Runtime and memory issues#
The runtime is the place where Python is installed and the code is actually executing, in the cloud somewhere.
If your runtime is repeatedly crashing, you’re probably running out of memory.
Make sure you aren’t loading data sets you don’t need.
If loading a new dataset, make it smaller