pandas index & multiindex in TableReport#1083
Conversation
|
todo:
|
|
I reduced the number of rows from 10 to 5 in the srkub homepage. BTW, not really related to this PR but in the home page if we want the report to take yet less vertical space one way is to give it a bit more horizontal space (either making the sk-landing-page a bit wider or giving the report more space compared to the code snippet on its right) because then the column filters select will drop to be on the same line as the tabs |
|
ok this one is ready for review here is an example to generate a report with multiple column and index levels: Details# %%
import datetime
import pandas as pd
import numpy as np
from skrub import TableReport
df = pd.DataFrame(
{
"A": ["one", "one", "two", "three"] * 6,
"B": ["A", "B", "C"] * 8,
"C": ["foo", "foo", "foo", "bar", "bar", "bar"] * 4,
"D": np.random.randn(24),
"E": np.random.randn(24),
"F": [datetime.datetime(2013, i, 1) for i in range(1, 13)]
+ [datetime.datetime(2013, i, 15) for i in range(1, 13)],
}
)
df = pd.pivot_table(
df,
values="E",
index=["B", "C"],
columns=["A"],
aggfunc=["sum", "mean"],
)
report = TableReport(df)
report
# %%
report.open() |
| order_by=None, | ||
| with_plots=True, | ||
| title=None, | ||
| max_top_slice_size=5, |
There was a problem hiding this comment.
Maybe top_rows and bottom_rows ? Or n_top_rows ?
Feels like max_top_slice_size is kind of long
There was a problem hiding this comment.
indeed it is long, but there are quite a few "rows" flying around, and we need to distinguish between the maximum number of displayed rows and the actual number so I wanted to be very explicit here.
note this is a parameter of a private helper, the parameter exposed to the user is just n_rows
GaelVaroquaux
left a comment
There was a problem hiding this comment.
LGTM, but I would prefer if the "!important" in CSS could be removed
yep I removed it already. it's just that pure has a selector that is quite specific already (table class name + nth pseudo-class for alternating rows + elem) and I didn't want to have to come up with an artificially specific one but actually I remembered I wrapped the report in an element with an id which comes in handy for that |
|
Merged, thanks @jeromedockes ! |
supersedes #1074
adds displaying pandas index, handle correctly multiIndex (both for index and columns) and index/columns level names if any are present
allows controlling how many rows are displayed in the sample table
also some refactoring of how the html table is constructed