Skip to content
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

DOC: edit docstring example to prevent segfault (#21824) #22368

Merged
Merged
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
10 changes: 6 additions & 4 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -6896,21 +6896,21 @@ def count(self, axis=0, level=None, numeric_only=False):
Constructing DataFrame from a dictionary:

>>> df = pd.DataFrame({"Person":
... ["John", "Myla", None, "John", "Myla"],
... ["John", "Myla", "Lewis", "John", "Myla"],
... "Age": [24., np.nan, 21., 33, 26],
... "Single": [False, True, True, True, False]})
>>> df
Person Age Single
0 John 24.0 False
1 Myla NaN True
2 None 21.0 True
2 Lewis 21.0 True
3 John 33.0 True
4 Myla 26.0 False

Notice the uncounted NA values:

>>> df.count()
Person 4
Person 5
Age 4
Single 5
dtype: int64
Expand All @@ -6920,7 +6920,7 @@ def count(self, axis=0, level=None, numeric_only=False):
>>> df.count(axis='columns')
0 3
1 2
2 2
2 3
3 3
4 3
dtype: int64
Expand All @@ -6931,7 +6931,9 @@ def count(self, axis=0, level=None, numeric_only=False):
Age
Person
John 2
Lewis 1
Myla 1

"""
axis = self._get_axis_number(axis)
if level is not None:
Expand Down