Reputation: 18983
In a julia notebook opened with vscode the dataframe output format is latex but the result is not correctly rendered:
> using DataFrames
> df = DataFrame(a=1:3)
\begin{tabular}{r|c}
& a\\
\hline
& Int64\\
\hline
1 & 1 \\
2 & 2 \\
3 & 3 \\
\end{tabular}
Is there a way to configure jupyter extension to get a well formatted output for julia dataframes?
I'm actually using vscode 1.53.2 and julia 1.6.0-rc1.
Upvotes: 3
Views: 1106
Reputation: 51
I update the show method like this:
using DataFrames
Base.show(io::IO, ::MIME"text/latex", df::AbstractDataFrame) = show(df, backend=:html, show_row_number=true, highlighters=:tf_html_default )
Then we can see the well formatted output from this line:
df = DataFrame(a=1:3)
Upvotes: 3
Reputation: 1
Unfortunately, Przemyslaw's answer doesn't actually display the table inline in the Jupyter notebook. It seems that the VSCode implementation requests LaTeX output which it asks MathJax to display. This seems to be broken for DataFrames.
An alternative which does display the table inline is the PrettyTables package.
> using PrettyTables
> pretty_table(df, backend=:html)
Upvotes: 0
Reputation: 42244
Try VSCodeServer.vscodedisplay(df)
, for an example:
using DataFrames
df = DataFrame(x=1:4,y=rand(4),z='a':'d')
VSCodeServer.vscodedisplay(df)
Upvotes: 1