Skip to content

BUG: sparse empty construction buggy #10079

Closed
@jreback

Description

@jreback

From SO

trains = np.arange(100)
tresholds = [10, 20, 30, 40, 50, 60]
tuples = []
for i in trains:
    for j in tresholds:
        tuples.append((i, j))

index = pd.MultiIndex.from_tuples(tuples, names=['trains', 'tresholds'])
matrix = np.empty((len(index), len(trains)))
matrix.fill(np.nan)
df = pd.DataFrame(matrix, index=index, columns=trains, dtype=float)

Fails

df.to_sparse()

Ok

df.iloc[0] = 0
df.to_sparse()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions