Skip to content

Should SparseArray.astype be dense or Sparse #23125

Closed
@TomAugspurger

Description

@TomAugspurger

Right now SparseArray.astype(numpy_dtype) is sparse:

In [6]: a = pd.SparseArray([0, 1, 0, 1])

In [7]: a.astype(np.dtype('float'))
Out[7]:
[0, 1.0, 0, 1.0]
Fill: 0
IntIndex
Indices: array([1, 3], dtype=int32)

This is potentially confusing. I did it to match the behavior of SparseSeries, but we may not want that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignBlockerBlocking issue or pull request for an upcoming releaseDtype ConversionsUnexpected or buggy dtype conversionsSparseSparse Data Type

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions