Skip to content

Commit d409b2d

Browse files
DOC: Fix PR07 for pandas.Series.div and pandas.Series.truediv (#58718)
* DOC: remove PR01 for pandas.Series.div and truediv * DOC: add PR01 for pandas.Series.div and truediv
1 parent daa6adf commit d409b2d

File tree

2 files changed

+58
-3
lines changed

2 files changed

+58
-3
lines changed

ci/code_checks.sh

-2
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
146146
-i "pandas.Series.cat.rename_categories PR01,PR02" \
147147
-i "pandas.Series.cat.reorder_categories PR01,PR02" \
148148
-i "pandas.Series.cat.set_categories PR01,PR02" \
149-
-i "pandas.Series.div PR07" \
150149
-i "pandas.Series.dt.as_unit PR01,PR02" \
151150
-i "pandas.Series.dt.ceil PR01,PR02" \
152151
-i "pandas.Series.dt.components SA01" \
@@ -239,7 +238,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
239238
-i "pandas.Series.to_frame SA01" \
240239
-i "pandas.Series.to_markdown SA01" \
241240
-i "pandas.Series.to_string SA01" \
242-
-i "pandas.Series.truediv PR07" \
243241
-i "pandas.Series.update PR07,SA01" \
244242
-i "pandas.Series.var PR01,RT03,SA01" \
245243
-i "pandas.Timedelta PR07,SA01" \

pandas/core/series.py

+58-1
Original file line numberDiff line numberDiff line change
@@ -6122,8 +6122,65 @@ def rmul(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series:
61226122
other, roperator.rmul, level=level, fill_value=fill_value, axis=axis
61236123
)
61246124

6125-
@Appender(ops.make_flex_doc("truediv", "series"))
61266125
def truediv(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series:
6126+
"""
6127+
Return Floating division of series and other, \
6128+
element-wise (binary operator `truediv`).
6129+
6130+
Equivalent to ``series / other``, but with support to substitute a
6131+
fill_value for missing data in either one of the inputs.
6132+
6133+
Parameters
6134+
----------
6135+
other : Series or scalar value
6136+
Series with which to compute division.
6137+
level : int or name
6138+
Broadcast across a level, matching Index values on the
6139+
passed MultiIndex level.
6140+
fill_value : None or float value, default None (NaN)
6141+
Fill existing missing (NaN) values, and any new element needed for
6142+
successful Series alignment, with this value before computation.
6143+
If data in both corresponding Series locations is missing
6144+
the result of filling (at that location) will be missing.
6145+
axis : {0 or 'index'}
6146+
Unused. Parameter needed for compatibility with DataFrame.
6147+
6148+
Returns
6149+
-------
6150+
Series
6151+
The result of the operation.
6152+
6153+
See Also
6154+
--------
6155+
Series.rtruediv : Reverse of the Floating division operator, see
6156+
`Python documentation
6157+
<https://docs.python.org/3/reference/datamodel.html#emulating-numeric-types>`_
6158+
for more details.
6159+
6160+
Examples
6161+
--------
6162+
>>> a = pd.Series([1, 1, 1, np.nan], index=["a", "b", "c", "d"])
6163+
>>> a
6164+
a 1.0
6165+
b 1.0
6166+
c 1.0
6167+
d NaN
6168+
dtype: float64
6169+
>>> b = pd.Series([1, np.nan, 1, np.nan], index=["a", "b", "d", "e"])
6170+
>>> b
6171+
a 1.0
6172+
b NaN
6173+
d 1.0
6174+
e NaN
6175+
dtype: float64
6176+
>>> a.divide(b, fill_value=0)
6177+
a 1.0
6178+
b inf
6179+
c inf
6180+
d 0.0
6181+
e NaN
6182+
dtype: float64
6183+
"""
61276184
return self._flex_method(
61286185
other, operator.truediv, level=level, fill_value=fill_value, axis=axis
61296186
)

0 commit comments

Comments
 (0)