10000 [PERF] use numexpr in dispatch_to_series by jbrockmendel · Pull Request #22284 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

[PERF] use numexpr in dispatch_to_series #22284

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 7 commits into from
Sep 8, 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
remove commented-out test code
  • Loading branch information
jbrockmendel committed Aug 11, 2018
commit e9748a06a7846cf1010367713801297da449a9ba
2 changes: 1 addition & 1 deletion asv_bench/asv.conf.json
8000
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// The Pythons you'd like to test against. If not provided, defaults
// to the current version of Python used to run `asv`.
// "pythons": ["2.7", "3.4"],
"pythons": ["2.7"],
"pythons": ["3.6"],

// The matrix of dependencies to test. Each key is the name of a
// package (in PyPI) and the values are version numbers. An empty
Expand Down
20 changes: 0 additions & 20 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -4946,31 +4946,11 @@ def _combine_match_columns(self, other, func, level=None, try_cast=True):
return self._constructor(new_data)

def _combine_const(self, other, func, errors='raise', try_cast=True):

if isinstance(other, DataFrame) and other._indexed_same(self):
assert False
return ops.dispatch_to_series(self, other, func)

new_data = self._data.eval(func=func, other=other,
errors=errors,
try_cast=try_cast)
return self._constructor(new_data)

def _compare_frame(self, other, func, str_rep):
# compare_frame assumes self._indexed_same(other)
return ops.dispatch_to_series(self, other, func, str_rep)
import pandas.core.computation.expressions as expressions

def _compare(a, b):
return {i: func(a.iloc[:, i], b.iloc[:, i])
for i in range(len(a.columns))}

new_data = expressions.evaluate(_compare, str_rep, self, other)
result = self._constructor(data=new_data, index=self.index,
copy=False)
result.columns = self.columns
return result

def combine(self, other, func, fill_value=None, overwrite=True):
"""
Perform column-wise combine with another DataFrame based on a
Expand Down
8 changes: 2 additions & 6 deletions pandas/core/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -1604,17 +1604,13 @@ def column_op(a, b):
return {i: func(a.iloc[:, i], b)
for i in range(len(a.columns))}

#new_data = {i: func(left.iloc[:, i], right)
# for i in range(len(left.columns))}
elif isinstance(right, ABCDataFrame):
assert right._indexed_same(left)

def column_op(a, b):
return {i: func(a.iloc[:, i], b.iloc[:, i])
for i in range(len(a.columns))}

#new_data = {i: func(left.iloc[:, i], right.iloc[:, i])
# for i in range(len(left.columns))}
elif isinstance(right, ABCSeries):
assert right.index.equals(left.index) # Handle other cases later

Expand Down Expand Up @@ -1795,7 +1791,7 @@ def f(self, other, axis=default_axis, level=None):
if not self._indexed_same(other):
self, other = self.align(other, 'outer',
level=level, copy=False)
return self._compare_frame(other, na_op, str_rep)
return dispatch_to_series(self, other, na_op, str_rep)

elif isinstance(other, ABCSeries):
return _combine_series_frame(self, other, na_op,
Expand All @@ -1820,7 +1816,7 @@ def f(self, other):
if not self._indexed_same(other):
raise ValueError('Can only compare identically-labeled '
'DataFrame objects')
return self._compare_frame(other, func, str_rep)
return dispatch_to_series(self, other, func, str_rep)

elif isinstance(other, ABCSeries):
return _combine_series_frame(self, other, func,
Expand Down
0