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

to_latex with MI column and index names #8336

Closed
hayd opened this issue Sep 20, 2014 · 3 comments
Closed

to_latex with MI column and index names #8336

hayd opened this issue Sep 20, 2014 · 3 comments
Labels
Bug IO LaTeX to_latex MultiIndex Regression Functionality that used to work in a prior pandas version
Milestone

Comments

@hayd
Copy link
Contributor

hayd commented Sep 20, 2014

I introduced/uncovered a bug here with #8219.

If you pass in DataFrame with MI index and col names it doesn't output correctly (and never did). Should be able to fix pretty easily, since it's my fault am assigning myself!

@hayd hayd added this to the 0.15.0 milestone Sep 20, 2014
@hayd hayd self-assigned this Sep 20, 2014
@jreback jreback added the Output-Formatting __repr__ of pandas objects, to_string label Sep 20, 2014
@jreback jreback modified the milestones: 0.15.1, 0.15.0 Sep 24, 2014
kotfic added a commit to kotfic/pandas that referenced this issue Nov 11, 2014
This is a potential resolution to
pandas-dev#8336
It borrows the same code flow from _get_formatted_index in
pandas.core.format
@jreback jreback modified the milestones: 0.16.0, Next Major Release Mar 6, 2015
kotfic added a commit to kotfic/pandas that referenced this issue Mar 26, 2015
This is a potential resolution to
pandas-dev#8336
It borrows the same code flow from _get_formatted_index in
pandas.core.format
@jorisvandenbossche
Copy link
Member

I also just stumbled upon this. And it does seem to be a regression, as it worked in 0.14:

In [1]: idx = pd.MultiIndex.from_product([['A0', 'A1', 'A2'],['B0','B1']])

In [2]: df = pd.DataFrame(np.random.random((6, 2)), index=idx, columns=['col1','
col2'])

In [3]: print df.to_latex()
\begin{tabular}{lrr}
\toprule
{} &      col1 &      col2 \\
A0 B0 &  0.465015 &  0.706859 \\
\midrule
   B1 &  0.768717 &  0.528846 \\
A1 B0 &  0.762849 &  0.801075 \\
   B1 &  0.391274 &  0.751734 \\
A2 B0 &  0.647738 &  0.039428 \\
   B1 &  0.437429 &  0.512462 \\
\bottomrule
\end{tabular}

and now in 0.16.0 the same gives:

In [53]: print df.to_latex()
\begin{tabular}{llrr}
\toprule
   &    &      col1 &      col2 \\
\midrule
A0 & B0 &  0.512408 &  0.441161 \\
A1 & B1 &  0.456337 &  0.472716 \\
\bottomrule
\end{tabular}

@jorisvandenbossche jorisvandenbossche added the Regression Functionality that used to work in a prior pandas version label Apr 17, 2015
@jorisvandenbossche jorisvandenbossche added Effort Low IO LaTeX to_latex and removed Output-Formatting __repr__ of pandas objects, to_string labels Aug 20, 2015
@toobaz
Copy link
Member

toobaz commented Apr 16, 2017

I think this was fixed (in current git at least):

In [3]: idx = pd.MultiIndex.from_product([['A0', 'A1', 'A2'],['B0','B1']])

In [4]: df = pd.DataFrame(np.random.random((6, 2)), index=idx, columns=['col1','col2'])

In [5]: print(df.to_latex())
\begin{tabular}{llrr}
\toprule
   &    &      col1 &      col2 \\
\midrule
A0 & B0 &  0.184294 &  0.850768 \\
   & B1 &  0.762865 &  0.842426 \\
A1 & B0 &  0.137573 &  0.266622 \\
   & B1 &  0.365801 &  0.512295 \\
A2 & B0 &  0.449834 &  0.631251 \\
   & B1 &  0.374689 &  0.269184 \\
\bottomrule
\end{tabular}

@jorisvandenbossche
Copy link
Member

Yes, this was actually already fixed in 0.16.1: closed by #9908

@jorisvandenbossche jorisvandenbossche modified the milestones: 0.16.1, Next Major Release Apr 16, 2017
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IO LaTeX to_latex MultiIndex Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants