Repository: pandas-dev/pandas

Issue:
GroupBy.mean() doctests failed due to comparison to nothing
#### Code Sample, a copy-pastable example if possible

[`GroupBy.mean()` doctests](https://pandas-docs.github.io/pandas-docs-travis/reference/api/pandas.core.groupby.GroupBy.mean.html#pandas.core.groupby.GroupBy.mean):

```python
        Groupby one column and return the mean of the remaining columns in
        each group.

        >>> df.groupby('A').mean()
        >>>
             B         C
        A
        1  3.0  1.333333
        2  4.0  1.500000

        Groupby two columns and return the mean of the remaining column.

        >>> df.groupby(['A', 'B']).mean()
        >>>
               C
        A B
        1 2.0  2
          4.0  1
        2 3.0  1
          5.0  2

        Groupby one column and return the mean of only particular column in
        the group.

        >>> df.groupby('A')['B'].mean()
        >>>
        A
        1    3.0
        2    4.0
        Name: B, dtype: float64
```

#### Problem description

Doctests should not have extra `>>>` which seems leading to comparison to nothing.

For instance, as below:

```python
Failed example:
    df.groupby('A').mean()
Expected nothing
Got:
         B         C
    A               
    1  3.0  1.333333
    2  4.0  1.500000
```

#### Expected Output

Doctest pass

#### Output of ``pd.show_versions()``

<details>

```
>>> pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 3.7.3.final.0
python-bits: 64
OS: Darwin
OS-release: 18.5.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.23.4
pytest: 4.4.1
pip: 19.0.3
setuptools: 40.8.0
Cython: None
numpy: 1.16.2
scipy: None
pyarrow: 0.13.0
xarray: None
IPython: None
sphinx: 2.0.1
patsy: None
dateutil: 2.8.0
pytz: 2019.1
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10.1
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
```

</details>



Discussion:

Resolving patch:
diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py
--- a/pandas/core/groupby/groupby.py
+++ b/pandas/core/groupby/groupby.py
@@ -1117,7 +1117,6 @@ def mean(self, *args, **kwargs):
         each group.
 
         >>> df.groupby('A').mean()
-        >>>
              B         C
         A
         1  3.0  1.333333
@@ -1126,7 +1125,6 @@ def mean(self, *args, **kwargs):
         Groupby two columns and return the mean of the remaining column.
 
         >>> df.groupby(['A', 'B']).mean()
-        >>>
                C
         A B
         1 2.0  2
@@ -1138,7 +1136,6 @@ def mean(self, *args, **kwargs):
         the group.
 
         >>> df.groupby('A')['B'].mean()
-        >>>
         A
         1    3.0
         2    4.0
@@ -2145,7 +2142,7 @@ def head(self, n=5):
         --------
 
         >>> df = pd.DataFrame([[1, 2], [1, 4], [5, 6]],
-                              columns=['A', 'B'])
+        ...                   columns=['A', 'B'])
         >>> df.groupby('A', as_index=False).head(1)
            A  B
         0  1  2
@@ -2172,7 +2169,7 @@ def tail(self, n=5):
         --------
 
         >>> df = pd.DataFrame([['a', 1], ['a', 2], ['b', 1], ['b', 2]],
-                              columns=['A', 'B'])
+        ...                   columns=['A', 'B'])
         >>> df.groupby('A').tail(1)
            A  B
         1  a  2


Test patch: