Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Pipe attrs to_html Jinja2 environmental variables #59193

Open
1 of 3 tasks
disarticulate opened this issue Jul 5, 2024 · 0 comments
Open
1 of 3 tasks

ENH: Pipe attrs to_html Jinja2 environmental variables #59193

disarticulate opened this issue Jul 5, 2024 · 0 comments
Labels
Enhancement Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@disarticulate
Copy link

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

Dataframe and Styler implement a .to_html function which allows using custom styles via jinja2 custom templates which can be accessed via https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.io.formats.style.Styler.from_custom_template.html

Templates exposes each cell as a dict in the format of:

{'type': 'td', 'value': '0.004', 'class': 'data row3 col4', 'is_visible': True, 'attributes': '', 'display_value': '0.004', 'id': 'row3_col4'}

Dataframes and Series appear to implement the necessary but ???:

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.attrs.html#pandas.DataFrame.attrs
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.attrs.html#pandas.Series.attrs

Though it's not clear these are the same things.

I'm trying to pipe a jupyter notebook to html, then from html pandoc it to Docx. This requires being able to set a attribute=value defined as custom-style="Footnote Text", which allows Pandoc to apply a docx style.

Feature Description

Figure out how to either add attributes from the series or dataframe or implement a Styler component which adds attributes which get put into the jinja2 template. It's clear this was intended, but not implemented.

Alternative Solutions

The alternative would have me making custom templates for every table I need, rather than allowing pandoc to naturally adapt styles

Additional Context

I could probably implement this feature but it's obfuscated how the render goes from accessing a cell and putting that into a render function.

I assume it can be a mirror image of the set_table_styles function and instead but set_table_attributes unless the intention was to use the Dataframe.attrs or Series.attrs.

Either way, some clear direction could get this implemented.

@disarticulate disarticulate added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

1 participant