10000 Safer is dtype by TomAugspurger · Pull Request #22975 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

Safer is dtype #22975

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Oct 4, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Revert "Take 2"
This reverts commit d88929f.
  • Loading branch information
TomAugspurger committed Oct 3, 2018
commit f6cc86028b18b16867ef545b07bdc8c19437daec
3 changes: 2 additions & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -4908,7 +4908,8 @@ def _combine_match_index(self, other, func, level=None):
return ops.dispatch_to_series(left, right, func)
else:
# fastpath --> operate directly on values
new_data = func(left.values.T, right.values).T
with np.errstate(all="ignore"):
new_data = func(left.values.T, right.values).T
return self._constructor(new_data,
index=left.index, columns=self.columns,
copy=False)
Expand Down
15 changes: 3 additions & 12 deletions pandas/core/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,6 @@ def maybe_upcast_for_op(obj):
return obj


def silent_truediv(x, y):
"""Like operator.truediv, but with NumPy warnings silenced."""
with np.errstate(all="ignore"):
return operator.truediv(x ,y)


silent_truediv.__name__ = 'truediv'
silent_truediv.__doc__ = operator.truediv.__doc__

# -----------------------------------------------------------------------------
# Reversed Operations not available in the stdlib operator module.
# Defining these instead of using lambdas allows us to reference them by name.
Expand All @@ -168,7 +159,7 @@ def rdiv(left, right):


def rtruediv(left, right):
return silent_truediv(right, left)
return right / left


def rfloordiv(left, right):
Expand Down Expand Up @@ -348,7 +339,7 @@ def _get_opstr(op, cls):
rmul: '*',
operator.sub: '-',
rsub: '-',
silent_truediv: '/',
operator.truediv: '/',
rtruediv: '/',
operator.floordiv: '//',
rfloordiv: '//',
Expand Down Expand Up @@ -1021,7 +1012,7 @@ def _create_methods(cls, arith_method, comp_method, bool_method, special):
radd=arith_method(cls, radd, special),
sub=arith_method(cls, operator.sub, special),
mul=arith_method(cls, operator.mul, special),
truediv=arith_method(cls, silent_truediv, special),
truediv=arith_method(cls, operator.truediv, special),
floordiv=arith_method(cls, operator.floordiv, special),
# Causes a floating point exception in the tests when numexpr enabled,
# so for now no speedup
Expand Down
6 changes: 0 additions & 6 deletions pandas/tests/frame/test_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -1030,9 +1030,3 @@ def test_alignment_non_pandas(self):
align(df, val, 'index')
with pytest.raises(ValueError):
align(df, val, 'columns')

def test_no_warning(self, all_arithmetic_operators):
df = pd.DataFrame({"A": [0.,0.], "B": [0., None]})
b = df['B']
with tm.assert_produces_warning(None):
getattr(df, all_arithmetic_operators)(b, 0)
0