Skip to content

BUG: SparseSeries/DataFrame non-float dtypes repr #13110

Closed
@sinhrks

Description

@sinhrks

Currently sparse don't actually support dtype other than float. These must be fixed with #667

Code Sample, a copy-pastable example if possible

1. bool dtype with fill_value raises IndexError
pd.SparseSeries([True, False, True, False, True], fill_value=False)
# IndexError: index out of bounds
2. truncated/DataFrame output coerces to float
pd.set_option('display.max_rows', 3)
pd.SparseSeries([True, False, True, False, True])
#0    1.0
#     ... 
#4    1.0
# dtype: float64
# BlockIndex
# Block locations: array([0], dtype=int32)
# Block lengths: array([5], dtype=int32)

pd.SparseDataFrame({'A': [True, False, True, False, True]})
#      A
#0  1.0
#1  0.0
#2  1.0
#3  0.0
#4  1.0

output of pd.show_versions()

on current master

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugOutput-Formatting__repr__ of pandas objects, to_stringSparseSparse Data Type

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions