-
- Notifications
You must be signed in to change notification settings - Fork 19.4k
ENH: multirow naive implementation Styler.to_latex part1 #43369
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
Changes from 4 commits
d7779b6 11ac603 121062f 20f9b31 f561651 1732772 318bc7b 6fa0b35 237bee2 File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -242,6 +242,25 @@ def test_multiindex_row(df): | |
| assert expected == s.to_latex(sparse_index=False) | ||
| | ||
| | ||
| def test_multirow_naive(df): | ||
| ridx = MultiIndex.from_tuples([("A", "a"), ("A", "b"), ("B", "c")]) | ||
| df.loc[2, :] = [2, -2.22, "de"] | ||
| df = df.astype({"A": int}) | ||
| ||
| df.index = ridx | ||
| expected = dedent( | ||
| """\ | ||
| \\begin{tabular}{llrrl} | ||
| & & A & B & C \\\\ | ||
| A & a & 0 & -0.61 & ab \\\\ | ||
| & b & 1 & -1.22 & cd \\\\ | ||
| B & c & 2 & -2.22 & de \\\\ | ||
| \\end{tabular} | ||
| """ | ||
| ) | ||
| s = df.style.format(precision=2) | ||
| assert expected == s.to_latex(multirow_align="naive") | ||
| ||
| | ||
| | ||
| def test_multiindex_row_and_col(df): | ||
| cidx = MultiIndex.from_tuples([("Z", "a"), ("Z", "b"), ("Y", "c")]) | ||
| ridx = MultiIndex.from_tuples([("A", "a"), ("A", "b"), ("B", "c")]) | ||
| | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest that the letters
AandBshould not be repeated in both the index and columns.What if you use these for the index?
I guess it will be easier to differentiate from the columns.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fully agree. silly oversight.