Introduction to base python and programming constructs
This the jupyter notebook for a two day course in Python for Data visualization and analysis. The material here covers basic Python programming concepts.
In the second day, we cover the usage of matplotlib
to create scientific
visualisations.
Day 1
- The
print
command, Hello world! and a quick walkthough Jupyter Notebooks. - The basic objects of Python:
int
,str
,float
andbool
. Arithmetic operations and concatenation. Thetype
function. str
objects. Accessing and manipulating strings.list
objects. Slicing and indexing lists.pop
andinsert
methods.
- The
dict
data structure. Learning about.keys
and.items
methods. How to update dictionaries - The
if
,else
andelif
construct. Conditionals. - The
for
construct. Iterating through alist
orstring
. Usingbreak
to exit a loop prematurely.
- Introducing functions. The
def
keyword. Defining and calling functions. Scope and keyword arguments. - Anonymous functions. The
lambda
keyword. - Built in Python functions:
zip
andenumerate
. - List comprehension.
- Series structure, basic operations on series.
- Indexing and selecting data, boolean masking.
- Delaing with missing values
- DataFrame structure. Working with rows and columns.
- Conditional selection.
- A case study: Olympic Games dataset.
- Using the
.groupby
method. Split-apply-combine dataframes. - Merging dataframes.
- Melting dataframes.
Day 2
- Introducing basic function of the
plot
function. - Using
plot
to create time series plots and scatterplots. - Use
matplotlib
marker codes to customize our graph. - Case study: Historical exchange rates for OECD and non-OECD countries.
- Using
pyplot.hist
to plot barcharts and histograms withmatplotlib
. - Customizing histograms.
- 2D histograms and hexbin plots.
- Using and customizing colorbars.
- Using
seaborn.distplot
andseaborn.kdeplot
. - Visualizing linear relationships.
- Using
stripplot
,swarmplot
,boxplot
,violinplot
,countplot
,barplot
andpointplot
.
Figure
level plots fromseaborn
:JointGrid
andjointplot
.PairGrid
,pairplot
andFacetGrid
.lmplot
for visualizing multiple linear regression.factorplot
for visualising ANNOVA and linear models with categorical inputs.