Skip to content

Commit 5beadb7

Browse files
DOC: Enforce Numpy Docstring Validation for pandas.Series.mul (#58580)
* DOC: add PR07 for pandas.Series.mul * DOC: remove PR07 for pandas.Series.mul * DOC: fit summary in single line * DOC: fit summary in single line
1 parent 4debd6d commit 5beadb7

File tree

2 files changed

+63
-2
lines changed

2 files changed

+63
-2
lines changed

ci/code_checks.sh

-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
203203
-i "pandas.Series.min RT03" \
204204
-i "pandas.Series.mod PR07" \
205205
-i "pandas.Series.mode SA01" \
206-
-i "pandas.Series.mul PR07" \
207206
-i "pandas.Series.ne PR07,SA01" \
208207
-i "pandas.Series.pad PR01,SA01" \
209208
-i "pandas.Series.plot PR02,SA01" \

pandas/core/series.py

+63-1
Original file line numberDiff line numberDiff line change
@@ -5973,14 +5973,76 @@ def rsub(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series:
59735973
other, roperator.rsub, level=level, fill_value=fill_value, axis=axis
59745974
)
59755975

5976-
@Appender(ops.make_flex_doc("mul", "series"))
59775976
def mul(
59785977
self,
59795978
other,
59805979
level: Level | None = None,
59815980
fill_value: float | None = None,
59825981
axis: Axis = 0,
59835982
) -> Series:
5983+
"""
5984+
Return Multiplication of series and other, element-wise (binary operator `mul`).
5985+
5986+
Equivalent to ``series * other``, but with support to substitute
5987+
a fill_value for missing data in either one of the inputs.
5988+
5989+
Parameters
5990+
----------
5991+
other : Series or scalar value
5992+
With which to compute the multiplication.
5993+
level : int or name
5994+
Broadcast across a level, matching Index values on the
5995+
passed MultiIndex level.
5996+
fill_value : None or float value, default None (NaN)
5997+
Fill existing missing (NaN) values, and any new element needed for
5998+
successful Series alignment, with this value before computation.
5999+
If data in both corresponding Series locations is missing
6000+
the result of filling (at that location) will be missing.
6001+
axis : {0 or 'index'}
6002+
Unused. Parameter needed for compatibility with DataFrame.
6003+
6004+
Returns
6005+
-------
6006+
Series
6007+
The result of the operation.
6008+
6009+
See Also
6010+
--------
6011+
Series.rmul : Reverse of the Multiplication operator, see
6012+
`Python documentation
6013+
<https://docs.python.org/3/reference/datamodel.html#emulating-numeric-types>`_
6014+
for more details.
6015+
6016+
Examples
6017+
--------
6018+
>>> a = pd.Series([1, 1, 1, np.nan], index=["a", "b", "c", "d"])
6019+
>>> a
6020+
a 1.0
6021+
b 1.0
6022+
c 1.0
6023+
d NaN
6024+
dtype: float64
6025+
>>> b = pd.Series([1, np.nan, 1, np.nan], index=["a", "b", "d", "e"])
6026+
>>> b
6027+
a 1.0
6028+
b NaN
6029+
d 1.0
6030+
e NaN
6031+
dtype: float64
6032+
>>> a.multiply(b, fill_value=0)
6033+
a 1.0
6034+
b 0.0
6035+
c 0.0
6036+
d 0.0
6037+
e NaN
6038+
dtype: float64
6039+
>>> a.mul(5, fill_value=0)
6040+
a 5.0
6041+
b 5.0
6042+
c 5.0
6043+
d 0.0
6044+
dtype: float64
6045+
"""
59846046
return self._flex_method(
59856047
other, operator.mul, level=level, fill_value=fill_value, axis=axis
59866048
)

0 commit comments

Comments
 (0)