- Packages (e.g. pyspark) contain modules (e.g. pyspark.sql), which in turn define classes, functions, etc. (e.g. pyspark.sql.HiveContext(SparkContext)).
- Load a package or a module by issuing
import numpy. You can then access its functions by
numpy.array([2,4,6]). If you want to type less, you can import
np, which allows you to call
- You can hand-pick single functions with
from numpy import arrayand can then directly call
array([2,4,6]), but this is discouraged as it could lead to namespace clashes.
- A possibility (although not recommended) is to use
from numpy import *. This imports all definitions in numpy directly. Again, not recommended.
The following two versions are equivalent: