groupby and last/first fails: ValueError: function does not reduce
#### Code Sample, a copy-pastable example if possible

```python
(tickets
    .groupby(by=['destination', 'departure'])
    .last()
)
```
#### Problem description

Fails by `ValueError: function does not reduce`: https://pastebin.com/rL60tgLm

<details>
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~/work/virtualenv/python3/lib/python3.6/site-packages/pandas/core/groupby.py in _cython_agg_blocks(self, how, alt, numeric_only, min_count)
   3652                 result, _ = self.grouper.aggregate(
-> 3653                     block.values, how, axis=agg_axis, min_count=min_count)
   3654             except NotImplementedError:

~/work/virtualenv/python3/lib/python3.6/site-packages/pandas/core/groupby.py in aggregate(self, values, how, axis, min_count)
   2313         return self._cython_operation('aggregate', values, how, axis,
-> 2314                                       min_count=min_count)
   2315 

~/work/virtualenv/python3/lib/python3.6/site-packages/pandas/core/groupby.py in _cython_operation(self, kind, values, how, axis, min_count)
   2269                 result, counts, values, labels, func, is_numeric,
-> 2270                 is_datetimelike, min_count)
   2271         elif kind == 'transform':

~/work/virtualenv/python3/lib/python3.6/site-packages/pandas/core/groupby.py in _aggregate(self, result, counts, values, comp_ids, agg_func, is_numeric, is_datetimelike, min_count)
   2331         else:
-> 2332             agg_func(result, counts, values, comp_ids, min_count)
   2333 

pandas/_libs/groupby.pyx in pandas._libs.groupby.group_last_object()

TypeError: group_last_object() takes exactly 4 positional arguments (5 given)

During handling of the above exception, another exception occurred:

UnboundLocalError                         Traceback (most recent call last)
~/work/virtualenv/python3/lib/python3.6/site-packages/pandas/core/groupby.py in f(self, **kwargs)
   1243                     return self._cython_agg_general(
-> 1244                         alias, alt=npfunc, **kwargs)
   1245                 except AssertionError as e:

~/work/virtualenv/python3/lib/python3.6/site-packages/pandas/core/groupby.py in _cython_agg_general(self, how, alt, numeric_only, min_count)
   3608         new_items, new_blocks = self._cython_agg_blocks(
-> 3609             how, alt=alt, numeric_only=numeric_only, min_count=min_count)
   3610         return self._wrap_agged_blocks(new_items, new_blocks)

~/work/virtualenv/python3/lib/python3.6/site-packages/pandas/core/groupby.py in _cython_agg_blocks(self, how, alt, numeric_only, min_count)
   3673                 # see if we can cast the block back to the original dtype
-> 3674                 result = block._try_coerce_and_cast_result(result)
   3675                 newb = block.make_block(result)

UnboundLocalError: local variable 'result' referenced before assignment

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
~/work/virtualenv/python3/lib/python3.6/site-packages/pandas/core/groupby.py in agg_series(self, obj, func)
   2356         try:
-> 2357             return self._aggregate_series_fast(obj, func)
   2358         except Exception:

~/work/virtualenv/python3/lib/python3.6/site-packages/pandas/core/groupby.py in _aggregate_series_fast(self, obj, func)
   2376                                     dummy)
-> 2377         result, counts = grouper.get_result()
   2378         return result, counts

pandas/_libs/src/reduce.pyx in pandas._libs.lib.SeriesGrouper.get_result()

pandas/_libs/src/reduce.pyx in pandas._libs.lib.SeriesGrouper.get_result()

pandas/_libs/src/reduce.pyx in pandas._libs.lib._get_result_array()

ValueError: function does not reduce

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
<ipython-input-61-4ee9b4b43807> in <module>()
      1 (tickets
----> 2     .groupby(by=['destination', 'departure'])
      3     .last()
      4 )

~/work/virtualenv/python3/lib/python3.6/site-packages/pandas/core/groupby.py in f(self, **kwargs)
   1247                 except Exception:
   1248                     result = self.aggregate(
-> 1249                         lambda x: npfunc(x, axis=self.axis))
   1250                     if _convert:
   1251                         result = result._convert(datetime=True)

~/work/virtualenv/python3/lib/python3.6/site-packages/pandas/core/groupby.py in aggregate(self, arg, *args, **kwargs)
   4289         versionadded=''))
   4290     def aggregate(self, arg, *args, **kwargs):
-> 4291         return super(DataFrameGroupBy, self).aggregate(arg, *args, **kwargs)
   4292 
   4293     agg = aggregate

~/work/virtualenv/python3/lib/python3.6/site-packages/pandas/core/groupby.py in aggregate(self, arg, *args, **kwargs)
   3730             # grouper specific aggregations
   3731             if self.grouper.nkeys > 1:
-> 3732                 return self._python_agg_general(arg, *args, **kwargs)
   3733             else:
   3734 

~/work/virtualenv/python3/lib/python3.6/site-packages/pandas/core/groupby.py in _python_agg_general(self, func, *args, **kwargs)
    937         for name, obj in self._iterate_slices():
    938             try:
--> 939                 result, counts = self.grouper.agg_series(obj, f)
    940                 output[name] = self._try_cast(result, obj, numeric_only=True)
    941             except TypeError:

~/work/virtualenv/python3/lib/python3.6/site-packages/pandas/core/groupby.py in agg_series(self, obj, func)
   2357             return self._aggregate_series_fast(obj, func)
   2358         except Exception:
-> 2359             return self._aggregate_series_pure_python(obj, func)
   2360 
   2361     def _aggregate_series_fast(self, obj, func):

~/work/virtualenv/python3/lib/python3.6/site-packages/pandas/core/groupby.py in _aggregate_series_pure_python(self, obj, func)
   2392                 if (isinstance(res, (Series, Index, np.ndarray)) or
   2393                         isinstance(res, list)):
-> 2394                     raise ValueError('Function does not reduce')
   2395                 result = np.empty(ngroups, dtype='O')
   2396 

ValueError: Function does not reduce
</details>

#### Expected Output

Latest item from each group.

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

<details>
INSTALLED VERSIONS
------------------
commit: None
python: 3.6.4.final.0
python-bits: 64
OS: Darwin
OS-release: 17.4.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: ru_RU.UTF-8
LOCALE: ru_RU.UTF-8

pandas: 0.22.0
pytest: None
pip: 9.0.1
setuptools: 38.5.1
Cython: None
numpy: 1.14.1
scipy: None
pyarrow: None
xarray: None
IPython: 6.2.1
sphinx: None
patsy: None
dateutil: 2.7.0
pytz: 2018.3
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: 1.0.1
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
</details>
