Skip to content

Conversation

lmarti
Copy link

@lmarti lmarti commented Apr 6, 2015

Currently, when IPython notebooks are converted to latex, pandas DataFrames are appear as raw (verbatim) text. One simple solution is to include a _repl_latex_ function. I have tried this solution and works. See ipython/ipython#8261

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 ipython/ipython#8261
@shoyer
Copy link
Member

shoyer commented Apr 6, 2015

This is a nice idea!

Could you please add a basic test? Could be something as simple as assert ds._repl_latex_() == ds.to_latex(), just so we know this doesn't get broken in the future.

Also, this will need a release note in the what's new:
http://pandas-docs.github.io/pandas-docs-travis/contributing.html#documenting-your-code



def _repr_latex_(self):
return self.to_latex()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a comment to note that this is for ipython? adding a reference to this GH issue would probably also be a good idea.

@jorisvandenbossche
Copy link
Member

Nice idea indeed, I was only wondering if there is a way to make this configurable? Maybe on the nbconvert side?
As I can imagine you don't always want a full tex table, eg when writing a tutorial where you want to have it look like console input/output

@jorisvandenbossche jorisvandenbossche added Enhancement Output-Formatting __repr__ of pandas objects, to_string labels Apr 6, 2015
@jorisvandenbossche jorisvandenbossche added this to the 0.16.1 milestone Apr 6, 2015
@lmarti
Copy link
Author

lmarti commented Apr 7, 2015

Well, yes... I was thinking of a simple fix... but it would be nice to be able to pass options in the way that you can pass them no to to_latex. Maybe store those options in a singleton and reuse them? Is there any similar situation in pandas?

@shoyer
Copy link
Member

shoyer commented Apr 7, 2015

We already have pd.set_options and pd.option_context: http://pandas.pydata.org/pandas-docs/version/0.16.0/options.html

So that would be a pretty easy way to add this customization if you're interested. But (from my perspective), that shouldn't be a requirement for this PR.

@jreback jreback modified the milestones: 0.17.0, 0.16.1 Apr 29, 2015
@jreback
Copy link
Contributor

jreback commented Jul 12, 2015

@lmarti can you update with a test and options as described above

@lmarti
Copy link
Author

lmarti commented Jul 13, 2015

@jreback yes! in the next couple of days. Sorry for the delay.

@jreback
Copy link
Contributor

jreback commented Aug 16, 2015

@lmarti can you add a test

@jreback
Copy link
Contributor

jreback commented Aug 20, 2015

@lmarti can you add a basic tests for this?

@jreback
Copy link
Contributor

jreback commented Sep 1, 2015

@lmarti pls update according to the comments

@jreback jreback modified the milestones: Next Major Release, 0.17.0 Sep 1, 2015
@jreback
Copy link
Contributor

jreback commented Oct 11, 2015

@lmarti can you update according to comments

@lmarti lmarti changed the title better pandas typesetting in ipython nbconvert --to latex ENC: better pandas typesetting in ipython nbconvert --to latex Oct 21, 2015
@lmarti
Copy link
Author

lmarti commented Oct 21, 2015

I have sent a new PR (#11399) that contains all the requested modifications. Thanks for the wait.

@lmarti lmarti closed this Oct 21, 2015
@jorisvandenbossche jorisvandenbossche modified the milestones: No action, Next Major Release Jul 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants