Skip to content

PERF: perf issue with dropna on frame #5815

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 1 commit into from
Jan 1, 2014
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Improvements to existing features
- perf improvements in Series datetime/timedelta binary operations (:issue:`5801`)
- `option_context` context manager now available as top-level API (:issue:`5752`)
- df.info() view now display dtype info per column (:issue: `5682`)
- perf improvements in DataFrame ``count/dropna`` for ``axis=1``

Bug Fixes
~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3952,7 +3952,7 @@ def count(self, axis=0, level=None, numeric_only=False):
counts = notnull(frame.values).sum(1)
result = Series(counts, index=frame._get_agg_axis(axis))
else:
result = DataFrame.apply(frame, Series.count, axis=axis)
result = notnull(frame).sum(axis=axis)

return result

Expand Down
28 changes: 28 additions & 0 deletions vb_suite/frame_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,33 @@ def f(K=100):
frame_isnull = Benchmark('isnull(df)', setup,
start_date=datetime(2012,1,1))

## dropna
setup = common_setup + """
data = np.random.randn(10000, 1000)
df = DataFrame(data)
df.ix[50:1000,20:50] = np.nan
df.ix[2000:3000] = np.nan
df.ix[:,60:70] = np.nan
"""
frame_dropna_axis0_any = Benchmark('df.dropna(how="any",axis=0)', setup,
start_date=datetime(2012,1,1))
frame_dropna_axis0_all = Benchmark('df.dropna(how="all",axis=0)', setup,
start_date=datetime(2012,1,1))

setup = common_setup + """
data = np.random.randn(10000, 1000)
df = DataFrame(data)
df.ix[50:1000,20:50] = np.nan
df.ix[2000:3000] = np.nan
df.ix[:,60:70] = np.nan
"""
frame_dropna_axis1_any = Benchmark('df.dropna(how="any",axis=1)', setup,
start_date=datetime(2012,1,1))

frame_dropna_axis1_all = Benchmark('df.dropna(how="all",axis=1)', setup,
start_date=datetime(2012,1,1))


#----------------------------------------------------------------------
# apply

Expand All @@ -298,3 +325,4 @@ def f(K=100):
"""
frame_apply_user_func = Benchmark('df.apply(lambda x: np.corrcoef(x,s)[0,1])', setup,
start_date=datetime(2012,1,1))