Exercises
Use IPython sessions for each exercise where practical. Each time you create or modify an array
, Series
or DataFrame
, display the result.
7.1 (Filling
array
s) Fill a 2-by-3array
with ones, a 3-by-3array
with zeros and a 2-by-5 array with7
s.7.2 (Broadcasting) Use
arange
to create a 2-by-2array
containing the numbers 0–3. Use broadcasting to perform each of the following operations on the originalarray
:Cube every element of the
array
.Add
7
to every element of thearray
.Multiply every element of the array by
2
.
7.3 (Element-Wise
array
Multiplication) Create a 3-by-3array
containing the even integers from2
through18
. Create a second 3-by-3array
containing the integers from9
down to1
, then multiply the firstarray
by the ...
Get Intro to Python for Computer Science and Data Science: Learning to Program with AI, Big Data and The Cloud 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.