Python Fundamentals


Figure 1

Value of 65.0 with weight_kg label stuck on it

Figure 2

Value of 65.0 with label weight_kg stuck on it, and value of 143.0 with label weight_lb stuck on it

Figure 3

Value of 100.0 with label weight_kg stuck on it, and value of 143.0 with label weight_lb stuck on it

Analyzing some wave-height data


Figure 1

'data' is a 3 by 3 numpy array containing row 0: ['A', 'B', 'C'], row 1: ['D', 'E', 'F'], and row 2: ['G', 'H', 'I']. Starting in the upper left hand corner, data[0, 0] = 'A', data[0, 1] = 'B', data[0, 2] = 'C', data[1, 0] = 'D', data[1, 1] = 'E', data[1, 2] = 'F', data[2, 0] = 'G', data[2, 1] = 'H', and data[2, 2] = 'I', in the bottom right hand corner.

Figure 2

Per-year maximum height is computed row-wise across all columns using numpy.max(data, axis=1). Per-year average wave height is computed column-wise across all rows using numpy.mean(data, axis=0).

Visualizing Tabular Data


Figure 1

Heat map representing the wave height from the first 50 days. Each cell is colored by value along a color gradient from blue to yellow.

Figure 2

A line graph showing the monthly average wave height over a 37 year period.

Figure 3

A line graph showing the maximum wave height per month over a 37 year period.

Figure 4

A line graph showing the minimum wave height per month over a 37 year period.

Figure 5

Three line graphs showing the daily average, maximum and minimum wave-heights over a 446-day period.

Figure 6

Three plots showing the average, maximum  and minimum waveheights plotted on a single pair of axes.

Figure 7

Global surface waveheight

Figure 8

Global surface waveheight with a colourbar

Storing Multiple Values in Lists


Figure 1

x is represented as a pepper shaker containing several packets of pepper. [x[0]] is represented as a pepper shaker containing a single packet of pepper. x[0] is represented as a single packet of pepper. x[0][0] is represented as single grain of pepper. Adapted from @hadleywickham.
hadleywickham-tweet

Repeating Actions with Loops


Figure 1

Loop variable 'num' being assigned the value of each element in the list `odds` in turn and then being printed

Analyzing Data from Multiple Files


Figure 1

Output from the first iteration of the for loop. Three line graphs showing the average, maximum and minimum waveheight in the 2000s.

Figure 2

Output from the second iteration of the for loop. Three line graphs showing the average, maximum and minimum waveheight in the 2010s.

Figure 3

Output from the third iteration of the for loop. Three line graphs showing the average, maximum and minimum waveheight in the 1980s.

Figure 4

1990s data highlighting NaNs

Making Choices


Figure 1

A flowchart diagram of the if-else construct that tests if variable num is greater than 100

Creating Functions


Figure 1

Labeled parts of a Python function definition