Closed
Description
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
I have confirmed this bug exists on the master branch of pandas.
Reproducible Example
midx = MultiIndex.from_product([["A", "B"], ["a", "b"], ["X", "Y"]], names=["zero", "one", "two"])
cidx = MultiIndex.from_product([["a", "b"], ["C", "D"], ["V", "W"]], names=["zero", "one", "two"])
df = DataFrame(np.arange(64).reshape(8,8), index=midx, columns=cidx)
styler = Styler(df)
styler.hide_index(level=1).hide_columns(level=0)
styler.hide_index([("A", "a", "X"), ("A", "b", "X")])
styler.hide_columns([("a", "C", "W"), ("a", "D", "V")])
styler
Issue Description
When using a MultiIndex and combining with hiding different levels and hiding specific rows/columns, some bugs appear.
Output is quite strange on second row for HTML output.
Also using LaTeX output:
>>> styler.to_latex()
\begin{tabular}{llrrrrrr}
& one & C & D & \multicolumn{2}{r}{C} & \multicolumn{2}{r}{D} \\
& two & V & W & V & W & V & W \\
zero & two & & & & & & \\
\multirow[c]{2}{*}{A} & & Y & 8 & 11 & 12 & 13 & 14 & 15 \\
& & Y & 24 & 27 & 28 & 29 & 30 & 31 \\
\multirow[c]{4}{*}{B} & \multirow[c]{2}{*}{} & X & 32 & 35 & 36 & 37 & 38 & 39 \\
& & Y & 40 & 43 & 44 & 45 & 46 & 47 \\
& \multirow[c]{2}{*}{} & X & 48 & 51 & 52 & 53 & 54 & 55 \\
& & Y & 56 & 59 & 60 & 61 & 62 & 63 \\
\end{tabular}
The above is a LaTeX error but if the number of columns is expanded to 9 then it renders like:
Expected Behavior
Clearly we want to align all the datapoints and have the hidden levels correctly hidden.
Installed Versions
master