Skip to content

BUG: concat with sparse not propogating default_fill_value #15737

Closed
@jreback

Description

@jreback

from #12174 (comment)

In [1]: df = pd.SparseDataFrame(np.random.choice([0., 1.], size=(5,5)), default_fill_value=0.)
   ...: 

In [2]: df
Out[2]: 
     0    1    2    3    4
0  0.0  1.0  1.0  0.0  0.0
1  1.0  1.0  1.0  0.0  1.0
2  0.0  1.0  0.0  1.0  0.0
3  1.0  1.0  1.0  0.0  1.0
4  1.0  0.0  0.0  1.0  1.0

In [3]: df.default_fill_value
Out[3]: 0.0

In [4]: pd.concat((df, df), axis=1)
Out[4]: 
     0    1    2    3    4    0    1    2    3    4
0  0.0  1.0  1.0  0.0  0.0  0.0  1.0  1.0  0.0  0.0
1  1.0  1.0  1.0  0.0  1.0  1.0  1.0  1.0  0.0  1.0
2  0.0  1.0  0.0  1.0  0.0  0.0  1.0  0.0  1.0  0.0
3  1.0  1.0  1.0  0.0  1.0  1.0  1.0  1.0  0.0  1.0
4  1.0  0.0  0.0  1.0  1.0  1.0  0.0  0.0  1.0  1.0

In [5]: pd.concat((df, df), axis=1).default_fill_value
Out[5]: nan

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReshapingConcat, Merge/Join, Stack/Unstack, ExplodeSparseSparse Data Type

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions