DOC: edit docstring example to prevent segfault (#21824) (#22368) · pandas-dev/pandas@70e6f7c (original) (raw)

Original file line number Diff line number Diff line change
@@ -6896,21 +6896,21 @@ def count(self, axis=0, level=None, numeric_only=False):
6896 6896 Constructing DataFrame from a dictionary:
6897 6897
6898 6898 >>> df = pd.DataFrame({"Person":
6899 - ... ["John", "Myla", None, "John", "Myla"],
6899 + ... ["John", "Myla", "Lewis", "John", "Myla"],
6900 6900 ... "Age": [24., np.nan, 21., 33, 26],
6901 6901 ... "Single": [False, True, True, True, False]})
6902 6902 >>> df
6903 6903 Person Age Single
6904 6904 0 John 24.0 False
6905 6905 1 Myla NaN True
6906 - 2 None 21.0 True
6906 + 2 Lewis 21.0 True
6907 6907 3 John 33.0 True
6908 6908 4 Myla 26.0 False
6909 6909
6910 6910 Notice the uncounted NA values:
6911 6911
6912 6912 >>> df.count()
6913 - Person 4
6913 + Person 5
6914 6914 Age 4
6915 6915 Single 5
6916 6916 dtype: int64
@@ -6920,7 +6920,7 @@ def count(self, axis=0, level=None, numeric_only=False):
6920 6920 >>> df.count(axis='columns')
6921 6921 0 3
6922 6922 1 2
6923 - 2 2
6923 + 2 3
6924 6924 3 3
6925 6925 4 3
6926 6926 dtype: int64
@@ -6931,7 +6931,9 @@ def count(self, axis=0, level=None, numeric_only=False):
6931 6931 Age
6932 6932 Person
6933 6933 John 2
6934 + Lewis 1
6934 6935 Myla 1
6936 +
6935 6937 """
6936 6938 axis = self._get_axis_number(axis)
6937 6939 if level is not None: