Groupby.apply has issues with printing command
#### Code Sample, a copy-pastable example if possible

```python
>>>import pandas as pd

>>>df = pd.DataFrame(data=[[1,2], [3, 4], [5, 6]], index=[10, 20, 30])
>>>out = df.groupby(level=0).apply(lambda x: print(x))

```
#### Problem description

When `print` is used within the `groupby.apply`, it seems that the function is applied to the first index twice. I am not sure if this behaviour is due to `print` function, or it actually occurs for any given function. The issue may not seem to be a big deal at first; however, when `groupby.apply` is combined with multiprocessing framework, it hampers the efficiency and speedup of the code.

#### Output:
```
    0  1
10  1  2
    0  1
10  1  2
    0  1
20  3  4
    0  1
30  5  6
```
#### Expected Output
```
    0  1
10  1  2
    0  1
20  3  4
    0  1
30  5  6
```
#### Output of ``pd.show_versions()``
<details>

INSTALLED VERSIONS
------------------
commit: None
python: 3.6.6.final.0
python-bits: 64
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 94 Stepping 3, GenuineIntel
byteorder: little
LC_ALL: None
LANG: en
LOCALE: None.None

pandas: 0.23.4
pytest: 3.8.2
pip: 19.0.2
setuptools: 40.4.3
Cython: 0.28.5
numpy: 1.14.2
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: 7.0.1
sphinx: 1.8.1
patsy: 0.5.0
dateutil: 2.7.3
pytz: 2018.5
blosc: None
bottleneck: 1.2.1
tables: 3.4.4
numexpr: 2.6.8
feather: None
matplotlib: 3.0.0
openpyxl: 2.5.8
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 1.1.1
lxml: 4.2.5
bs4: 4.6.3
html5lib: 1.0.1
sqlalchemy: 1.2.12
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

</details>
