Numerical Python (NumPy) is an open source Python library for scientific computing. NumPy provides a host of features that allow a Python programmer to work with high-performance arrays and matrices. NumPy arrays are stored more efficiently than Python lists and allow mathematical operations to be vectorized, which results in significantly higher performance than with looping constructs in Python.
pandas builds upon functionality provided by NumPy. The pandas library relies heavily on the NumPy array for the implementation of the pandas Series
and DataFrame
objects, and shares many of its features such as being able to slice elements and perform vectorized operations. It is therefore useful to spend some time going over NumPy arrays before diving into pandas.
In this chapter, we will cover the following topics about NumPy arrays:
Since NumPy is a prerequisite for pandas, and you have already installed pandas, NumPy is ready to be used. All that is required to do to use NumPy is to import the library and so all that is required for the examples in this chapter and for most of this book is the following import command:
In [1]: # this allows us to access numpy using the # np. prefix import numpy as np
This makes the top-level functions of NumPy available in the np
namespace. This is a common practice when using NumPy, and this book will follow this convention for accessing NumPy functionality.
3.145.109.8