Description
Code Sample, a copy-pastable example if possible
>>> import pandas as pd
>>> df1 = pd.DataFrame({'a': [1]})
>>> df2 = pd.DataFrame({'a': [1.0]})
>>> df1.merge(df2, on='a')
>>> df1.merge(df2, on='a', how='left')
a
0 1
>>> df1.merge(df2, on='a', how='right')
a
0 1
Problem description
I don't know if this is an issue, it's just something I noticed while working on #31278 . The right value 1.0
gets coerced to the dtype of the left dataframe when using how='left'
, and I would have expected the left value 1
to get coerced to the dtype of the right dataframe when using how='right'
Expected Output
>>> df1.merge(df2, on='a', how='right')
a
0 1.0
Output of pd.show_versions()
INSTALLED VERSIONS
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}
{k:<17}: {stat}