Skip to content

Commit 15741ca

Browse files
DOC: Enforce Numpy Docstring Validation for pandas.Series.add (#58673)
* DOC: add PR07 pandas.Series.add * DOC: remove PR07 pandas.Series.add
1 parent 8500629 commit 15741ca

File tree

2 files changed

+57
-2
lines changed

2 files changed

+57
-2
lines changed

Diff for: ci/code_checks.sh

-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
141141
-i "pandas.RangeIndex.start SA01" \
142142
-i "pandas.RangeIndex.step SA01" \
143143
-i "pandas.RangeIndex.stop SA01" \
144-
-i "pandas.Series.add PR07" \
145144
-i "pandas.Series.case_when RT03" \
146145
-i "pandas.Series.cat PR07" \
147146
-i "pandas.Series.cat.add_categories PR01,PR02" \

Diff for: pandas/core/series.py

+57-1
Original file line numberDiff line numberDiff line change
@@ -5957,8 +5957,64 @@ def gt(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series:
59575957
other, operator.gt, level=level, fill_value=fill_value, axis=axis
59585958
)
59595959

5960-
@Appender(ops.make_flex_doc("add", "series"))
59615960
def add(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series:
5961+
"""
5962+
Return Addition of series and other, element-wise (binary operator `add`).
5963+
5964+
Equivalent to ``series + other``, but with support to substitute a fill_value
5965+
for missing data in either one of the inputs.
5966+
5967+
Parameters
5968+
----------
5969+
other : Series or scalar value
5970+
With which to compute the addition.
5971+
level : int or name
5972+
Broadcast across a level, matching Index values on the
5973+
passed MultiIndex level.
5974+
fill_value : None or float value, default None (NaN)
5975+
Fill existing missing (NaN) values, and any new element needed for
5976+
successful Series alignment, with this value before computation.
5977+
If data in both corresponding Series locations is missing
5978+
the result of filling (at that location) will be missing.
5979+
axis : {0 or 'index'}
5980+
Unused. Parameter needed for compatibility with DataFrame.
5981+
5982+
Returns
5983+
-------
5984+
Series
5985+
The result of the operation.
5986+
5987+
See Also
5988+
--------
5989+
Series.radd : Reverse of the Addition operator, see
5990+
`Python documentation
5991+
<https://docs.python.org/3/reference/datamodel.html#emulating-numeric-types>`_
5992+
for more details.
5993+
5994+
Examples
5995+
--------
5996+
>>> a = pd.Series([1, 1, 1, np.nan], index=["a", "b", "c", "d"])
5997+
>>> a
5998+
a 1.0
5999+
b 1.0
6000+
c 1.0
6001+
d NaN
6002+
dtype: float64
6003+
>>> b = pd.Series([1, np.nan, 1, np.nan], index=["a", "b", "d", "e"])
6004+
>>> b
6005+
a 1.0
6006+
b NaN
6007+
d 1.0
6008+
e NaN
6009+
dtype: float64
6010+
>>> a.add(b, fill_value=0)
6011+
a 2.0
6012+
b 1.0
6013+
c 1.0
6014+
d 1.0
6015+
e NaN
6016+
dtype: float64
6017+
"""
59626018
return self._flex_method(
59636019
other, operator.add, level=level, fill_value=fill_value, axis=axis
59646020
)

0 commit comments

Comments
 (0)