Skip to content

combine_first converts dtype from bool to object #3552

Closed
@wilsaj

Description

@wilsaj

possibly related to #3041 but still present in 0.11 and current HEAD (23f6058)

In [1]: import pandas as pd

In [2]: import numpy as np

In [3]: df1 = pd.DataFrame([[np.nan, 3.,True], [-4.6, np.nan, True], [np.nan, 7., False]])

In [4]: df2 = pd.DataFrame([[-42.6, np.nan, True], [-5., 1.6, False]], index=[1, 2])

In [5]: df1[2]
Out[5]:
0     True
1     True
2    False
Name: 2, dtype: bool

In [6]: df2[2]
Out[6]:
1     True
2    False
Name: 2, dtype: bool

In [7]: df1.combine_first(df2)[2]
Out[7]:
0     True
1     True
2    False
Name: 2, dtype: object

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