NumPy Array
noun
say it: “NUM-pye uh-RAY” /ˈnʌmpaɪ əˈreɪ/
A block of many values of the same type, such as numbers, that NumPy stores side by side and can do math on all at once.
What is a NumPy array?
A NumPy array (its type is ndarray) holds many values of one type, packed side by side. Math on it works on every
value at once, which a Python list can't do: a list times 2 repeats the list.
import numpy as np
cups = [120, 95, 140]
print(cups * 2) # [120, 95, 140, 120, 95, 140]
print(np.array(cups) * 2) # [240 190 280]
In a sentence
- “Multiplying the NumPy array by 2 doubled every number in it.”
- “to_numpy() handed back the column's values as a NumPy array.”
Level: Journeyman · More Python terms at this level
Updated