Skip to content

CLN/DOC: DataFrame.count remove references to "level" #54395

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
Aug 4, 2023
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
13 changes: 2 additions & 11 deletions asv_bench/benchmarks/frame_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,19 +512,10 @@ def setup(self, axis):
self.df_mixed = self.df.copy()
self.df_mixed["foo"] = "bar"

self.df.index = MultiIndex.from_arrays([self.df.index, self.df.index])
self.df.columns = MultiIndex.from_arrays([self.df.columns, self.df.columns])
self.df_mixed.index = MultiIndex.from_arrays(
[self.df_mixed.index, self.df_mixed.index]
)
self.df_mixed.columns = MultiIndex.from_arrays(
[self.df_mixed.columns, self.df_mixed.columns]
)

def time_count_level_multi(self, axis):
def time_count(self, axis):
self.df.count(axis=axis)

def time_count_level_mixed_dtypes_multi(self, axis):
def time_count_mixed_dtypes(self, axis):
self.df_mixed.count(axis=axis)


Expand Down
5 changes: 2 additions & 3 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -10991,9 +10991,8 @@ def count(self, axis: Axis = 0, numeric_only: bool = False):

Returns
-------
Series or DataFrame
Series
For each column/row the number of non-NA/null entries.
If `level` is specified returns a `DataFrame`.

See Also
--------
Expand Down Expand Up @@ -11051,7 +11050,7 @@ def count(self, axis: Axis = 0, numeric_only: bool = False):
else:
result = notna(frame).sum(axis=axis)

return result.astype("int64").__finalize__(self, method="count")
return result.astype("int64", copy=False).__finalize__(self, method="count")

def _reduce(
self,
Expand Down