Skip to content

Commit 70e6f7c

Browse files
DOC: edit docstring example to prevent segfault (#21824) (#22368)
1 parent 2a2d1cf commit 70e6f7c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pandas/core/frame.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -6896,21 +6896,21 @@ def count(self, axis=0, level=None, numeric_only=False):
68966896
Constructing DataFrame from a dictionary:
68976897
68986898
>>> df = pd.DataFrame({"Person":
6899-
... ["John", "Myla", None, "John", "Myla"],
6899+
... ["John", "Myla", "Lewis", "John", "Myla"],
69006900
... "Age": [24., np.nan, 21., 33, 26],
69016901
... "Single": [False, True, True, True, False]})
69026902
>>> df
69036903
Person Age Single
69046904
0 John 24.0 False
69056905
1 Myla NaN True
6906-
2 None 21.0 True
6906+
2 Lewis 21.0 True
69076907
3 John 33.0 True
69086908
4 Myla 26.0 False
69096909
69106910
Notice the uncounted NA values:
69116911
69126912
>>> df.count()
6913-
Person 4
6913+
Person 5
69146914
Age 4
69156915
Single 5
69166916
dtype: int64
@@ -6920,7 +6920,7 @@ def count(self, axis=0, level=None, numeric_only=False):
69206920
>>> df.count(axis='columns')
69216921
0 3
69226922
1 2
6923-
2 2
6923+
2 3
69246924
3 3
69256925
4 3
69266926
dtype: int64
@@ -6931,7 +6931,9 @@ def count(self, axis=0, level=None, numeric_only=False):
69316931
Age
69326932
Person
69336933
John 2
6934+
Lewis 1
69346935
Myla 1
6936+
69356937
"""
69366938
axis = self._get_axis_number(axis)
69376939
if level is not None:

0 commit comments

Comments
 (0)