Skip to content
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

BUG: NaN in multi-index and to_latex() #14249

Closed
eXcuvator opened this issue Sep 19, 2016 · 1 comment · Fixed by #20797
Closed

BUG: NaN in multi-index and to_latex() #14249

eXcuvator opened this issue Sep 19, 2016 · 1 comment · Fixed by #20797

Comments

@eXcuvator
Copy link

Code Sample, a copy-pastable example if possible

I was trying to find a small reproducible code for a larger issue that I wanted to report. On the way there, I stumbled across this (probably related) issue:

# test data frame:
>>> test
Out[36]: 
  robustness  value  change
0   baseline    NaN   -14.5
# as expected: 
>>> test.set_index(['robustness', 'value']).to_csv()
Out[34]: 'robustness,value,change\nbaseline,,-14.5\n'

And here's what to_latex() makes out of it:

>>> test.set_index(['robustness', 'value']).to_latex()
Traceback (most recent call last):
  File "/usr/local/anaconda2/envs/myenv2/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2885, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-35-901bbd119ed6>", line 1, in <module>
    test.set_index(['robustness', 'value']).to_latex()
  File "/usr/local/anaconda2/envs/myenv2/lib/python2.7/site-packages/pandas/core/frame.py", line 1601, in to_latex
    encoding=encoding)
  File "/usr/local/anaconda2/envs/myenv2/lib/python2.7/site-packages/pandas/core/format.py", line 638, in to_latex
    latex_renderer.write_result(self.buf)
  File "/usr/local/anaconda2/envs/myenv2/lib/python2.7/site-packages/pandas/core/format.py", line 824, in write_result
    blank = ' ' * len(lev2[0])
IndexError: list index out of range

Expected Output

output of pd.show_versions()

pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 2.7.11.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.0-36-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.18.0
nose: None
pip: 8.1.1
setuptools: 21.2.1
Cython: None
numpy: 1.11.0
scipy: 0.17.0
statsmodels: None
xarray: None
IPython: 4.1.2
sphinx: None
patsy: 0.4.1
dateutil: 2.4.2
pytz: 2015.7
blosc: None
bottleneck: None
tables: None
numexpr: 2.5.2
matplotlib: 1.5.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.13
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None

@jreback jreback changed the title Indexing is behaving weirdly in to_latex() BUG: NaN in multi-index and to_latex() Sep 19, 2016
@jreback jreback added this to the Next Major Release milestone Sep 19, 2016
@jreback
Copy link
Contributor

jreback commented Sep 19, 2016

there are a number of bugs w.r.t. latex output. This is not handling the nan's correctly in a multi-index level. pull requests from the community are needed.

@jreback jreback modified the milestones: Next Major Release, 0.23.0 Feb 27, 2018
@jreback jreback modified the milestones: 0.23.0, Next Major Release Apr 14, 2018
@jreback jreback modified the milestones: Next Major Release, 0.23.0 Apr 24, 2018
toobaz pushed a commit that referenced this issue Apr 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants