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

concat Series[sparse] converts sp_values to NaN #24371

Closed
TomAugspurger opened this issue Dec 20, 2018 · 3 comments
Closed

concat Series[sparse] converts sp_values to NaN #24371

TomAugspurger opened this issue Dec 20, 2018 · 3 comments
Labels
Reshaping Concat, Merge/Join, Stack/Unstack, Explode Sparse Sparse Data Type
Milestone

Comments

@TomAugspurger
Copy link
Contributor

In [1]: import pandas as pd

In [2]: s = pd.Series(pd.SparseArray([0, 1], fill_value=0))

In [3]: pd.concat([s, s], axis=1, keys=['a', 'b'])
Out[3]:
     a    b
0  NaN  NaN
1  1.0  1.0
@TomAugspurger TomAugspurger added Reshaping Concat, Merge/Join, Stack/Unstack, Explode Sparse Sparse Data Type labels Dec 20, 2018
@TomAugspurger
Copy link
Contributor Author

Note, the only happens when we choose to return a SparseDataFrame instead of a DataFrame of sparse values. I thought we changed that to return a DataFrame..

@TomAugspurger
Copy link
Contributor Author

This is the behavior on 0.23.4

In [1]: import pandas as pd

In [2]: s = pd.Series(pd.SparseArray([0, 1], fill_value=0))

In [3]: pd.concat([s, s], axis=1, keys=['a', 'b'])
Out[3]:
   a  b
0  1  1
1  1  1

@TomAugspurger
Copy link
Contributor Author

Huh, those are dense values too:

In [13]: pd.concat([s, s], axis=1, keys=['a', 'b']).a.values
Out[13]: array([1, 1])

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

No branches or pull requests

2 participants