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: Allow pd.set_option to control the uuid4 seed used in pd.io.formats.style.Renderer #58593

Closed
1 of 3 tasks
thisiswhereitype opened this issue May 6, 2024 · 2 comments
Closed
1 of 3 tasks
Labels
Enhancement Styler conditional formatting using DataFrame.style

Comments

@thisiswhereitype
Copy link

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

When running Notebooks with HTML output of tables, the uuid for each tables css class changes between runs creating uneeded diffing.

This it to prevent name collisions but results in a random uuid4 string for each table.

Feature Description

The uuid instance could optionally be seeded: https://stackoverflow.com/a/41186895

A config option, say styler.html.uuid_seed would allow users to optionally set and reset it for reproducibility or otherwise.
This would be kept as module state to be shared by all Styler objects, resulting in import level reproducibility.

Already Styler's may be passed id's to use in place of uuids. Permitting the default to remain the same.

The implementation of StylerRenderer's init would be altered to share the uuid state.

Alternative Solutions

Alternatively a StylerRenderer Singleton Factory might be implemented.

Additional Context

https://stackoverflow.com/a/41186895 - UUID seeding.
Relevant init line
Describe config docs

@thisiswhereitype thisiswhereitype added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels May 6, 2024
@attack68
Copy link
Contributor

This is quite an esoteric use. Not particularly enthusiastic about adding a pandas option for this functionality.

You can directly instantiate a Styler with a specified id

from pandas.io.formats.style import Styler
styler = Styler(df, uuid="my_id")

can be used instead of:

styler = df.style

Alernatively create a factory:

def styler(df):
    return Styler(df, uuid="default_id")

styler(df)

@attack68 attack68 added Styler conditional formatting using DataFrame.style and removed Needs Triage Issue that has not been reviewed by a pandas team member labels May 11, 2024
@thisiswhereitype
Copy link
Author

Okay thanks for the comments - I can use a factory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Styler conditional formatting using DataFrame.style
Projects
None yet
Development

No branches or pull requests

2 participants