Appendix BIntroduction to NumPy and Pandas

In this appendix you will learn to use two popular Python libraries used by data scientists—NumPy and Pandas. These libraries are commonly used during the data exploration and feature engineering phase of a project. The examples in this appendix require the use of Jupyter Notebooks.

NumPy

NumPy is a math library for Python that allows for fast and efficient manipulation of arrays. The main object provided by NumPy is a homogenous multidimensional array called an ndarray. All the elements of an ndarray must be of the same data type, and dimensions are referred to as axes in NumPy terminology.

To use NumPy in a Python project, you typically add the following import statement to your Python file:

import numpy as np

The lowercase alias np is a standard convention for referring to NumPy in Python projects.

Creating NumPy Arrays

There are a number of ways in which you can create an ndarray. To create an ndarray object out of a three-element Python list, use the np.array() statement. The following code snippet, when ...

Get Machine Learning for iOS Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.