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 2s3 * 2Out[46]:a 2b 4c 6dtype: 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 ...

Start Free Trial

No credit card required