I would like find the most common string value in `animal` when aggregating data by `id`, if the count is the same, I would like to pick the last value of `animal`.

```
   id   animal       date
0   1    dog      2018-01-01
1   1    dog      2018-01-02
2   1    cat      2018-01-03
3   2    cat      2018-01-01
4   3    dog      2018-01-01
5   4   fish      2018-01-01
6   5    dog      2018-01-01
7   5    cat      2018-01-02

```

The output should look something like:

```
   id animal
0  1   dog
1  2   cat
2  3   dog
3  4   fish
4  5   cat

```

I haven't been able to get this to work properly. I tried using `pd.get_dummies` and counting but not look. Ideally, the solution will use in build, vectorised pandas/numpy, i.e. filtering, join, np.where, etc as `groupby.apply`is very slow and data is somewhat sizable.