Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: concat with sparse not propogating default_fill_value #15737

Closed
jreback opened this issue Mar 20, 2017 · 2 comments · Fixed by #28425
Closed

BUG: concat with sparse not propogating default_fill_value #15737

jreback opened this issue Mar 20, 2017 · 2 comments · Fixed by #28425
Labels
Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode Sparse Sparse Data Type

Comments

@jreback
Copy link
Contributor

jreback commented Mar 20, 2017

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
@jreback jreback added Bug Difficulty Intermediate Reshaping Concat, Merge/Join, Stack/Unstack, Explode Sparse Sparse Data Type labels Mar 20, 2017
@jreback jreback added this to the Next Major Release milestone Mar 20, 2017
@jreback
Copy link
Contributor Author

jreback commented Mar 20, 2017

cc @mdgoldberg if you'd like to take a stab at this.

@hexgnu
Copy link
Contributor

hexgnu commented Feb 12, 2018

So I took a somewhat stab at this.

the problem here is that BlockManager strips out default_fill_value. I started going down the road of adding in SparseBlockManager, but it felt really hamfisted to me and introduced a bunch of new branches in the code.

Also I know from other discussions #19239 that this might be a waste of time.

Thoughts @jreback, or @TomAugspurger ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode Sparse Sparse Data Type
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants