Return Multiplication of series and other, element-wise (binary operator `mul`). Equivalent to ``series * other``, but with support to substitute a fill_value for missing data in either one of the inputs. Parameters ---------- other : Series or scal
(
self,
other,
level: Level | None = None,
fill_value: float | None = None,
axis: Axis = 0,
)
| 7190 | ) |
| 7191 | |
| 7192 | def mul( |
| 7193 | self, |
| 7194 | other, |
| 7195 | level: Level | None = None, |
| 7196 | fill_value: float | None = None, |
| 7197 | axis: Axis = 0, |
| 7198 | ) -> Series: |
| 7199 | """ |
| 7200 | Return Multiplication of series and other, element-wise (binary operator `mul`). |
| 7201 | |
| 7202 | Equivalent to ``series * other``, but with support to substitute |
| 7203 | a fill_value for missing data in either one of the inputs. |
| 7204 | |
| 7205 | Parameters |
| 7206 | ---------- |
| 7207 | other : Series or scalar value |
| 7208 | With which to compute the multiplication. |
| 7209 | level : int or name |
| 7210 | Broadcast across a level, matching Index values on the |
| 7211 | passed MultiIndex level. |
| 7212 | fill_value : None or float value, default None (NaN) |
| 7213 | Fill existing missing (NaN) values, and any new element needed for |
| 7214 | successful Series alignment, with this value before computation. |
| 7215 | If data in both corresponding Series locations is missing |
| 7216 | the result of filling (at that location) will be missing. |
| 7217 | axis : {0 or 'index'} |
| 7218 | Unused. Parameter needed for compatibility with DataFrame. |
| 7219 | |
| 7220 | Returns |
| 7221 | ------- |
| 7222 | Series |
| 7223 | The result of the operation. |
| 7224 | |
| 7225 | See Also |
| 7226 | -------- |
| 7227 | Series.rmul : Reverse of the Multiplication operator, see |
| 7228 | `Python documentation |
| 7229 | <https://docs.python.org/3/reference/datamodel.html#emulating-numeric-types>`_ |
| 7230 | for more details. |
| 7231 | |
| 7232 | Examples |
| 7233 | -------- |
| 7234 | >>> a = pd.Series([1, 1, 1, np.nan], index=["a", "b", "c", "d"]) |
| 7235 | >>> a |
| 7236 | a 1.0 |
| 7237 | b 1.0 |
| 7238 | c 1.0 |
| 7239 | d NaN |
| 7240 | dtype: float64 |
| 7241 | >>> b = pd.Series([1, np.nan, 1, np.nan], index=["a", "b", "d", "e"]) |
| 7242 | >>> b |
| 7243 | a 1.0 |
| 7244 | b NaN |
| 7245 | d 1.0 |
| 7246 | e NaN |
| 7247 | dtype: float64 |
| 7248 | >>> a.multiply(b, fill_value=0) |
| 7249 | a 1.0 |