Skip to content

BUG: filling doesn't work well for sparse blocks #6949

Closed
@immerrr

Description

@immerrr
In [1]: pd.__version__
Out[1]: '0.13.1'

In [2]: pd.DataFrame({'a': pd.SparseArray([1,2,3, np.nan, np.nan]), 'b': [1,2,3,np.nan,np.nan]})
Out[2]: 
    a   b
0   1   1
1   2   2
2   3   3
3 NaN NaN
4 NaN NaN

[5 rows x 2 columns]

In [3]: _2.reindex(_2.index[1:], fill_value=10.)
Out[3]: 
    a   b
1   2   2
2   3   3
3  10 NaN
4  10 NaN

[4 rows x 2 columns]

Also, this looks weird, I'd expect sparse array to preserve nans:

In [3]: pd.SparseArray([np.nan, np.nan], fill_value=0.0).to_dense()
Out[3]: array([ 0.,  0.])

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions