Series.replace throws TypeError only on large dataset
#### Code Sample, a copy-pastable example if possible

```python
d = 1000000
df = pd.DataFrame({'A': np.random.randint(1,100,d)})
mapvalue = {i: i+1 for i in range(d)}
res = df['A'].replace(mapvalue)

```
#### Problem description

This throws "_TypeError: Cannot compare types 'ndarray(dtype=int32)' and 'int'_".

What's weird is that, the code works fine when d = 100000, 10000, 1000 or lower. The error occurs only when d = 1000000

I found that if I changed line 3 to `mapvalue = {i: i+1 for i in range(100)}`, the problem goes away. However, the above behavior is still weird.

pandas version: 0.24.2
numpy version: 1.16.2