Learning Objectives

Python Overview

In R I Want In Python I Use
Base R numpy
dplyr/tidyr pandas
ggplot2 matplotlib/seaborn

Numpy Arrays

Useful functions over vectors

  • In R, we have functions operate on objects (e.g. log(x), sort(x), etc).

  • Python also has functions that operate on objects. But objects usually have functions associated with them directly. You access these functions by a period after the object name. These functions are called “methods”. Use tab completion to scroll through the available methods of an object.

    Python

    vec.sort() # sort
    vec.min() # minimum
    vec.max() # maximum
    vec.mean() # mean
    vec.sum() # sum
    vec.var() # variance
  • But there are still loads of useful functions that operate on objects.

    Python

    np.sort(vec)
    np.min(vec)
    np.max(vec)
    np.mean(vec)
    np.sum(vec)
    np.var(vec)
    np.size(vec)
    np.exp(vec)
    np.log(vec)

Booleans (Python’s logicals)