Skip to content

Commit 8b0f22f

Browse files
committed
ENH: speed regression in DataFrame.dropna / DataFrame.count(axis=1)
1 parent cc46392 commit 8b0f22f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pandas/core/frame.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2827,7 +2827,11 @@ def count(self, axis=0, level=None, numeric_only=False):
28272827
if len(frame._get_axis(axis)) == 0:
28282828
result = Series(0, index=frame._get_agg_axis(axis))
28292829
else:
2830-
result = DataFrame.apply(frame, Series.count, axis=axis)
2830+
if axis == 1:
2831+
counts = notnull(frame.values).sum(1)
2832+
result = Series(counts, index=frame._get_agg_axis(axis))
2833+
else:
2834+
result = DataFrame.apply(frame, Series.count, axis=axis)
28312835

28322836
# what happens with empty DataFrame
28332837
if isinstance(result, DataFrame):

0 commit comments

Comments
 (0)