# Introduction to NumPy

Get acquainted with NumPy, a Python library used to store arrays of numbers, and learn basic syntax and functionality.

Start## Key Concepts

Review core concepts you need to learn to master this subject

NumPy Arrays

Creating NumPy Arrays from files

NumPy element-wise arithmetic operations

Accessing NumPy Array elements by index

Indexing NumPy elements using conditionals

NumPy element-wise logical operations

NumPy Arrays

NumPy Arrays

```
# Import the NumPy module, aliased as 'np'
import numpy as np
# NumPy Arrays can be created with a list
my_array = np.array([1, 2, 3, 4])
```

*NumPy* (short for “Numerical Python”) is a Python module used for numerical computing, creating arrays and matrices, and performing very fast operations on those data structures. The core of NumPy is a multidimensional Array object.

The NumPy `.array()`

method is used to create new NumPy Arrays.

- 1Sarah records her second-grade class’s grades in an online spreadsheet. Her web browser records that she visited that spreadsheet, in addition to every other site she’s visited. Those sites record…
- 2To use NumPy with Python, import it at the top of your file using the following line: import numpy as np Writing as np allows us to use np as a shorthand for NumPy, which saves us time when cal…
- 3NumPy includes a powerful data structure known as an
*array*. A NumPy array is a special type of list. It’s a data structure that organizes multiple items. Each item can be of any type (strings, … - 4Typically, you won’t be entering data directly into an array. Instead, you’ll be importing the data from somewhere else. We’re able to transform CSV (comma-separated values) files into arrays usin…
- 5Generally, NumPy arrays are more efficient than lists. One reason is that they allow you to do
*element-wise operations*. An element-wise operation allows you to quickly perform an operation, such … - 6Arrays can also be added to or subtracted from each other in NumPy, assuming the arrays have the same number of elements. When adding or subtracting arrays in NumPy, each element will be added/sub…
- 7In Python, we can create lists that are made up of other lists. Similarly, in NumPy we can create an array of arrays. If the arrays that make up our bigger array are all the same size, then it has …
- 8NumPy allows us to select elements from an array using their indices. Consider the one-dimensional array a = np.array([5, 2, 7, 0, 11]) If we wanted to select the first element in this array, we…
- 9Selecting elements from a 2-d array is very similar to selecting them from a 1-d array, we just have two indices to select from. The syntax for selecting from a 2-d array is a[row,column] where a i…
- 10Another useful thing that arrays can do is perform element-wise
*logical operations*. For instance, suppose we want to know how many elements in an array are greater than 5. We can easily write som…

## What you'll create

Portfolio projects that showcase your new skills

## How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory