From d4b0eadac00e6e9de849a1741618942b3357b878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Mart=C3=AD?= Date: Mon, 6 Apr 2015 15:37:19 -0300 Subject: [PATCH] better pandas typesetting in ipython nbconvert --to latex Currently, when IPython notebooks are converted to latex, pandas `DataFrame`s are appear as raw (verbatim) text. One simple solution is to include a `_repl_latex_` function. I have tried this solution and works. See https://github.com/ipython/ipython/issues/8261 --- pandas/core/frame.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index f700d4316842c..de06044785891 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -1428,7 +1428,10 @@ def to_latex(self, buf=None, columns=None, col_space=None, colSpace=None, if buf is None: return formatter.buf.getvalue() - + + def _repr_latex_(self): + return self.to_latex() + def info(self, verbose=None, buf=None, max_cols=None, memory_usage=None, null_counts=None): """ Concise summary of a DataFrame.