Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion pandas/core/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,52 @@ def _get_op_name(op, special):
e NaN -2.0
"""

_mod_example_FRAME = """
**Using a scalar argument**

>>> df = pd.DataFrame([2, 4, np.nan, 6.2], index=["a", "b", "c", "d"],
... columns=['one'])
>>> df
one
a 2.0
b 4.0
c NaN
d 6.2
>>> df.mod(3, fill_value=-1)
one
a 2.0
b 1.0
c 2.0
d 0.2

**Using a DataFrame argument**

>>> df = pd.DataFrame(dict(one=[np.nan, 2, 3, 14], two=[np.nan, 1, 1, 3]),
... index=['a', 'b', 'c', 'd'])
>>> df
one two
a NaN NaN
b 2.0 1.0
c 3.0 1.0
d 14.0 3.0
>>> other = pd.DataFrame(dict(one=[np.nan, np.nan, 6, np.nan],
... three=[np.nan, 10, np.nan, -7]),
... index=['a', 'b', 'd', 'e'])
>>> other
one three
a NaN NaN
b NaN 10.0
d 6.0 NaN
e NaN -7.0
>>> df.mod(other, fill_value=3)
one three two
a NaN NaN NaN
b 2.0 3.0 1.0
c 0.0 NaN 1.0
d 2.0 NaN 0.0
e NaN -4.0 NaN
"""

_op_descriptions = {
# Arithmetic Operators
'add': {'op': '+',
Expand All @@ -418,7 +464,7 @@ def _get_op_name(op, special):
'mod': {'op': '%',
'desc': 'Modulo',
'reverse': 'rmod',
'df_examples': None},
'df_examples': _mod_example_FRAME},
'pow': {'op': '**',
'desc': 'Exponential power',
'reverse': 'rpow',
Expand Down