Skip to content

BUG?: can't print the head of a sparse dataframe in 0.21.0 #18551

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

Closed
lesshaste opened this issue Nov 28, 2017 · 3 comments · Fixed by #18924
Closed

BUG?: can't print the head of a sparse dataframe in 0.21.0 #18551

lesshaste opened this issue Nov 28, 2017 · 3 comments · Fixed by #18924
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string Sparse Sparse Data Type
Milestone

Comments

@lesshaste
Copy link

lesshaste commented Nov 28, 2017

import pandas as pd
df = pd.DataFrame([['a','b'],['c','d']])
S = pd.get_dummies(df, columns=[1], sparse=True)
print(S.head(1))

Problem description

You get:

TypeError: values must be SparseArray

However in pandas 0.20.3 it works OK

Expected Output

In [4]: print(S.head(1))

   0  1_b  1_d
0  a    1    0

Output of pd.show_versions()

pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.5.2.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.0-98-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_GB.UTF-8

pandas: 0.21.0
pytest: None
pip: 9.0.1
setuptools: 36.7.1
Cython: 0.27.3
numpy: 1.13.3
scipy: 1.0.0
pyarrow: None
xarray: None
IPython: 6.2.1
sphinx: None
patsy: 0.4.1
dateutil: 2.6.1
pytz: 2017.3
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.1.0
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: 1.0.2
lxml: None
bs4: 4.6.0
html5lib: 1.0b10
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

@lesshaste lesshaste changed the title Regression: can't print the head of a sparse dataframe in 0.21.0? Regression: can't print the head of a sparse dataframe in 0.21.0 Nov 28, 2017
@lesshaste lesshaste changed the title Regression: can't print the head of a sparse dataframe in 0.21.0 BUG?: can't print the head of a sparse dataframe in 0.21.0 Nov 29, 2017
@jreback
Copy link
Contributor

jreback commented Nov 29, 2017

cc @kernc
cc @Licht-T

seems buggy

@jreback jreback added Bug Difficulty Intermediate Output-Formatting __repr__ of pandas objects, to_string Sparse Sparse Data Type labels Nov 29, 2017
@jreback jreback added this to the Next Major Release milestone Nov 29, 2017
@jreback
Copy link
Contributor

jreback commented Dec 1, 2017

xref to #16874 which is the underlying issue, though maybe not the cause of this particular.

@hexgnu
Copy link
Contributor

hexgnu commented Feb 1, 2018

This will be fixed by #18924 (comment)

I will add to that PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string Sparse Sparse Data Type
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants