Open dougbrn opened 2 months ago
This code is likely what we're after, it alters the default representation without converting it to a styler object:
def my_style(df:NestedFrame):
return (df.style.format({"nested": ""}))
def _my_repr_html_(self) -> str | None:
return self.pipe(my_style)._repr_html_() # <<<< !!! HERE !!!
NestedFrame._repr_html_ = _my_repr_html_
Note that one quirk of this is that my_style needs to know what columns to style manually, so we may need to trigger this in add_nested calls and reassert the styling.
Connected to #64
We have control over the dataframe output within Pandas: https://pandas.pydata.org/docs/user_guide/style.html
When left unstyled, Pandas tries to print the dataframe directly into the cell values. We should have a custom rendering that changes this to be some simple representative value, like:
<NestedFrame>
. Optionally we could try to give this some more descriptive metadata, but I worry about the overhead of calculating such information if the user doesn't need it. e.g.<NestedFrame (length=350)>