Skip to content

merge or join fails if the left input dataframe contains a column of float32 #1849

@aheilbut

Description

@aheilbut

A merge or join involving a left DataFrame that has single precision floats will fail. Seems to be OK if the right dataframe has float32; these get cast to float64 (which they probably shouldn't be)

import numpy as np
import pandas
a = np.random.randint(0, 5, 100)
df = pandas.DataFrame({'a': a})
s = pandas.DataFrame( pandas.Series(np.random.random(5).astype('f'), name='md') )
df.merge(s, left_on='a', right_index=True) # this is OK
df['b'] = np.random.randint(0, 5, 100)
df.merge(s, left_on='a', right_index=True) # this is OK
df['c'] = np.random.random(100).astype('Float64')
df.merge(s, left_on='a', right_index=True) # this is OK
df['d'] = np.random.random(100).astype('Float32')
print df.dtypes
df.merge(s, left_on='a', right_index=True) # this fails

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions