Join error, possibly caused by dtype inferrence
#### Code Sample, a copy-pastable example if possible

```python
def reform(df,error_only=True):

    melted=df.melt(id_vars=['station','day','source','index'])
    splited = melted['index'].str.split('_', expand=True)
    melted['type']=splited[0]
    reformed=None
    melted['uid']= melted['station']+'_'+ melted['type']+';'+melted['source']
    for day,daydf in melted.groupby(['day']):
        pivotdf=daydf.pivot(index='uid',columns='variable',values='value')
        pivotdf.columns = [c +'_{}'.format(day) for c in pivotdf.columns if c !='uid' ]
        pivotdf=pivotdf.reset_index()
        pivotdf['key']=pivotdf['uid'].str.split(';',expand=True)[0].astype(str)
        if reformed is None:
            reformed=pivotdf
        else:
            print(reformed.dtypes,pivotdf.dtypes)
            print(reformed.tail(4))
            print(pivotdf.tail(4))
            reformed = reformed.join(pivotdf, on ='key')
        print(pivotdf.dtypes)

    return(concat(reformed,axis=1))

```
#### Problem description

I'm using pandas 0.24.2, installed with conda.

The issue  is occuring at the join step. pandas throws an error despite the fact that both column keys are the same. I obtain the following error `ValueError: You are trying to merge on object and int64 columns. If you wish to proceed you should use pd.concat`

This seems to stem from the  `_maybe_coerce_merge_keys method`.

This is probably due to the fact that the station column is a string/object that is composed of numbers. I would assume that the current checking relies on the first few character to infer dtype and that the shown dtype is not used, as both columns are always indicated as object during the print.

Here is the dtype print before the join
```python
uid         object
25%_0      float64
50%_0      float64
75%_0      float64
count_0    float64
max_0      float64
mean_0     float64
min_0      float64
std_0      float64
key         object
dtype: object 
uid         object
25%_1      float64
50%_1      float64
75%_1      float64
count_1    float64
max_1      float64
mean_1     float64
min_1      float64
std_1      float64
key         object
dtype: object
```

The key columns is composed of data like `123456_level`. I have also just done a test reversing the order of the string components to obtain 'level_123456'. But this did not change a thing.

#### Expected Output

I would expect that the columns are identified properly as object/string and that no dtype error is thrown during join/merge.

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

<details>

[paste the output of ``pd.show_versions()`` here below this line]
>>> pandas.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 3.6.6.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: AMD64 Family 22 Model 48 Stepping 1, AuthenticAMD
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None

pandas: 0.24.2
pytest: None
pip: 18.1
setuptools: 40.6.3
Cython: None
numpy: 1.16.2
scipy: 1.2.1
pyarrow: None
xarray: None
IPython: 7.2.0
sphinx: None
patsy: 0.5.1
dateutil: 2.7.5
pytz: 2018.7
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 3.0.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml.etree: None
bs4: None
html5lib: None
sqlalchemy: 1.2.15
pymysql: None
psycopg2: 2.7.6.1 (dt dec pq3 ext lo64)
jinja2: None
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None
</details>
