April 2015
Beginner to intermediate
504 pages
8h 36m
English
Arithmetic operations (+, -, /, *, and so on) can be applied either to a Series or between two Series objects. When applied to a single Series, the operation is applied to all of the values in that Series. The following code demonstrates arithmetic operations applied to a Series object by multiplying the values in s3 by 2. The result is a new Series with the new values (s3 is unchanged).
In [46]: # multiply all values in s3 by 2 s3 * 2 Out[46]: a 2 b 4 c 6 dtype: int64
The preceding code is also roughly equivalent to the following code, which creates a new series from a scalar value using the index from s3. It has the same result, but it is not as efficient, as alignment is performed between the Series objects instead ...
Read now
Unlock full access