time | section | concepts | outcomes |
---|---|---|---|
09-10 | 1.1.1 | anaconda3 | understand install location, create and update virtual environments |
1.1.2 | jupyter | download course material, open notebooks, edit in web browser | |
1.1.3 | testing | execute the hello world example in jupyter python env | |
break | |||
10-11 | 1.2.1 | python syntax | practice data structures, conditional statements, flow control |
1.2.2 | functions | understand modules | |
1.2.3 | files, directories | navigate the file system, read, write data files | |
break | |||
11-12 | 1.3.1 | tabular data | understand how to read, write, and process survey data |
1.3.2 | subset, substitute | and reshape | |
1.3.3 | summarize | aggregate, combine, join operations | |
12-13 | lunch | anaconda, continued | try to resolve anaconda, psychopy installation problems |
# update anaconda, spyder
conda update anaconda
conda install spyder=5.0.5
# update packages in env
conda update --all
# list envs
conda env list
# start jupyter notebook
jupyter notebook
# comment: test anaconda3 and jupyter notebooks
print("hello world")
Python is an interpreted language* which can be used in two ways:
user:host:~$ python
Python 3.5.1 (default, Oct 23 2015, 18:05:06)
[GCC 4.8.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 2 + 2
4
>>> print("Hello World")
Hello World
.py
extension after the name of your file:user:host:~$ python my_script.py
Hello World
A convenient and powerful way to use interactive-mode Python is via a Jupyter Notebook, or similar browser-based interface.
This particularly lends itself to data analysis since the notebook records a history of commands and shows output and graphs immediately in the browser.
There are several ways you can run a Jupyter(-style) notebook - locally installed on your computer or hosted as a service on the web. Today we will use a Jupyter notebook service provided by Google: https://colab.research.google.com (Colaboratory).
Go to https://colab.research.google.com and login with your Google account.
Select NEW NOTEBOOK → NEW PYTHON 3 NOTEBOOK - a new notebook will be created.
Type some Python code in the top cell, eg:
print("Hello Jupyter !")
Shift-Enter to run the contents of the cell
You can add new cells.
Insert → Insert Code Cell
NOTE: When the text on the left hand of the cell is: In [*]
(with an asterisk rather than a number), the cell is still running. It's usually best to wait until one cell has finished running before running the next.
Let's begin writing some code in our notebook.