I’d like to display a dataframe without secondary header of types in jupyter cell output but can not figure out how to do it. My best attempt prints HTML that I want but does not render it.
using DataFrames
df = DataFrame(a=1:2, b=3:4)
show(stdout, MIME("text/html"), df; eltypes=false)
1 Like
PrettyTables.jl has a nosubheader
option for this.
1 Like
You can just do show(df; nosubheader = true)
. show
for DataFrame
forwards keyword arguments to pretty_table
1 Like
This gives a result in plain text which does not look as good
1 Like
This works but renders with a different theme for some reason
The reason is that show
for data frame has a custom theme.
The issue is that by default display
is used to show things in Jupyter Notebook.
@Ronis_BR - in Use PrettyTables.jl as HTML backend by ronisbr · Pull Request #3096 · JuliaData/DataFrames.jl · GitHub I think we should make sure that users can properly customize displaying of data frames in Jupyter Notebooks. OK?
1 Like
Hi @artemsolod,
In the released version, PrettyTables is not used to render HTML. It will be available when that PR mentioned by @bkamins is merged. This is the reason why you are seeing a different theme when using PrettyTables (side note: this default print will change in the next release of PrettyTables).
Hi @bkamins,
In this PR, we already have the possibility to pass any argument to PrettyTables just as the text backend so that the user can customize the output:
5 Likes
For future reference, I have found that I can use HTML()
to render with my original code
function show_noheader(df)
iobuf = IOBuffer()
show(iobuf, MIME("text/html"), df; eltypes=false)
HTML(String(take!(iobuf)))
end
1 Like