question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

API/ENH: Styler template arguments

See original GitHub issue

Usecase - I have a Styler subclass with a new template that I want to pass some arbitrary stuff into - which currently there isn’t a great way to do (right now I’m overriding and re-implementing .render()).

Open to suggestions on the api, but I was thinking of adding template_args argument that would be passed to the template.

from pandas.formats.style import Styler
from jinja2 import Template

class MyStyler(Styler):
    template = Template("""
        .... omitted
        {{ my_value_1 }}
        """)

MyStyler(df, template_args={'my_value_1': '...'}).render()

xref #11610 (master tracker)

pandas 0.19.2

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
chris-b1commented, Apr 3, 2017

Very nice! Might be nice to wrap the subclassing into some kind of factory function to lessen the jinja2 knowledge required? Roughly

def make_styler_subclass(template_folder, visible_template_name):
    loader = ChoiceLoader([
        FileSystemLoader(template_folder),
        PackageLoader("pandas.formats")
    ])
    class MyStyler(pd.formats.style.Styler):
        env = Environment(loader=loader)
        template = env.get_template(visible_template_name)
    return MyStyler
0reactions
TomAugspurgercommented, May 31, 2017

Closed by https://github.com/pandas-dev/pandas/issues/15649 (I think solved everything, just forget to close it).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Format Your Paper - APA Style (7th ed.)
This is an APA format template document in Google Docs. ... evaluate, or replicate the study or argument; Put each appendix on a...
Read more >
A Template Showing How to Use APA Format
A TEMPLATE SHOWING HOW TO USE APA FORMAT. 2. Abstract. The abstract states the question the paper was designed to answer and reports...
Read more >
General Format - Purdue OWL
Cite your source automatically in MLA or APA format ... APA site where you can find a complete list of all the errors...
Read more >
Academic Writing Style Guide: How to Format an APA Paper
The main ones are the introduction, methods, arguments/discussions, and conclusions. Depending on the department or subject requirements, the ...
Read more >
APA Style | APA Sample Papers | Excelsior Online Writing Lab
When writing an APA-style paper, sometimes a sample paper is the best reference! OWL has a collection of sample papers to help guide...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found