Although pandas is a very important package for data analysis, it can work in conjunction with two other packages: SciPy and NumPy.
SciPy
scipy.cluster
scipy.constants
scipy.fftpack
scipy.integrate
scipy.interpolate
scipy.io
scipy.lib
scipy.linalg
scipy.misc
scipy.optimize
scipy.signal
scipy.sparse
scipy.spatial
scipy.special
scipy.stats
scipy.weave
Documentation opens directly in the window, from which we can exit by pressing q.
SciPy features very technical modules. For the purposes of this book, we are particularly interested in combining with NumPy, so the focus of this chapter is on this second package primarily.
NumPy
At the beginning of Python's development, programmers soon found themselves having to incorporate tools for scientific computation. Their first attempt resulting in the Numeric package, which was developed in 1995, followed by an alternative package called Numarray. The merging of the functions of these two packages came to life in 2006 with NumPy.
Options for Storing Data
Data Type | Description |
---|---|
bool_ | Boolean (True or False), stored as a byte |
int_ | Default integer type (same as C long; normally either int64 or int32) |
intc | Identical to C int (normally int32 or int64) |
intp | Integer used for indexing (same as C ssize_t; normally either int32 or int64) |
int8 | Byte (-128 to 127) |
int16 | Integer (-32768 to 32767) |
int32 | Integer (-2147483648 to 2147483647) |
int64 | Integer (-9223372036854775808 to 9223372036854775807) |
uint8 | Unsigned integer (0 to 255) |
uint16 | Unsigned integer (0 to 65535) |
uint32 | Unsigned integer (0 to 4294967295) |
uint64 | Unsigned integer (0 to 18446744073709551615) |
float_ | Shorthand for float64 |
float16 | Half-precision float: sign bit, 5-bit exponent, 10-bit mantissa |
float32 | Single-precision float: sign bit, 8-bit exponent, 23-bit mantissa |
float64 | Double-precision float: sign bit, 11-bit exponent, 52-bit mantissa |
complex_ | Shorthand for complex128 |
complex64 | Complex number, represented by two 32-bit floats (real and imaginary components) |
complex128 | Complex number, represented by two 64-bit floats (real and imaginary components) |
NumPy: Generating Random Numbers and Seeds
NumPy contains other advanced mathematics modules, such as numPy.linalg for linear algebra, fft for Fourier transform, and a number functions for financial analysis, such as interest and futures calculations. You can find all the necessary documentation about NumPy features at https://docs.scipy.org/doc/ .
Summary
NumPy and SciPy are two very important packages used by data analysts. Each has a variety of features, but the packages can be combined to create random datasets, for example.