Extremely slow custom function in pandas aggregate
I have a DataFrame of ~3 million rows and 5 columns. I take a subset of ~450000 rows from it and I want to apply a function on a moving window (the index is a datetime). If use a custom function the performance is extremely low.

This is a reproducible example of my problem:

```
import numpy as np
import pandas as pd

import time

def mymean(x):
    return x.mean()

nrows = 3000000
ntrue = 450000
window = 5

rng = pd.date_range('2015-01-01 00:00:00', periods=nrows, freq='min')
data = pd.DataFrame({ 'A': rng, 'B' : np.random.randn(len(rng)), 'C' : np.random.randn(len(rng)), 'D' : np.random.randn(len(rng)), 'E' : np.zeros(len(rng), dtype=bool)})

data.loc[np.random.choice(np.arange(nrows), ntrue, replace=False), 'E'] = True

start_time = time.time()

channel_data = data[data['E'] == True].sort_values('A')
channel_data['A'] = pd.to_datetime(channel_data['A'],format='%Y-%m-%d %H:%M:%S').dt.floor('d')
channel_data = channel_data.set_index('A')

rolling_data = channel_data.rolling('{}D'.format(window)).agg({ 'B': mymean })

rolling_data = rolling_data.groupby(rolling_data.index.floor('d')).last()[window:]

print(rolling_data['B'].std())

print('Time needed: {} seconds'.format(time.time() - start_time))
```

If I use `mymean` in the `aggregate` line, the execution time is:
`Time needed: 50.55572175979614 seconds`

If I use `np.mean` or I just pass in the string 'mean':
`Time needed: 0.09020495414733887 seconds`

#### Output of ``pd.show_versions()``

INSTALLED VERSIONS
------------------
commit: None
python: 3.5.6.final.0
python-bits: 64
OS: Linux
OS-release: 4.15.0-50-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_GB.UTF-8

pandas: 0.23.4
pytest: None
pip: 10.0.1
setuptools: 40.2.0
Cython: None
numpy: 1.14.2
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: 6.5.0
sphinx: 1.7.9
patsy: None
dateutil: 2.7.3
pytz: 2018.5
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 3.0.0
openpyxl: None
xlrd: 1.1.0
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.9999999
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
