Skip to content

ENH: Styler.bar extended to allow centering about the mean, value or callable #42301

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

Merged
merged 14 commits into from
Jul 9, 2021

Conversation

attack68
Copy link
Contributor

@attack68 attack68 commented Jun 29, 2021

This refactors Styler.bar to allow more flexible arguments to align bars, and an additional keyword props akin to other builtin methods that allow some customisation, demonstrated in the new user guide (image below)

All previous tests pass with minor formatting alterations.

As a follow-on I should improve the original testing for this function - it is sporadic and unstructured.

Screen Shot 2021-06-29 at 14 53 56

@attack68 attack68 changed the title [WIP] ENH: Styler.bar extended to allow centering about the mean, value or callable ENH: Styler.bar extended to allow centering about the mean, value or callable Jun 29, 2021
@attack68 attack68 marked this pull request as ready for review June 29, 2021 13:22
@attack68 attack68 added Styler conditional formatting using DataFrame.style Enhancement labels Jun 29, 2021
@jreback jreback added this to the 1.4 milestone Jul 4, 2021
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

looks fine. anything need updating in the doc-string?

@@ -2831,3 +2785,166 @@ def _highlight_between(
else np.full(data.shape, True, dtype=bool)
)
return np.where(g_left & l_right, props, "")


def _bar(
Copy link
Contributor

Choose a reason for hiding this comment

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

could consider moving style* things to a separate dir e.g. pandas/io/formats/style/* and then have flexibility to for example move some utilities to own modules. (obviously for future)

@attack68
Copy link
Contributor Author

attack68 commented Jul 5, 2021

looks fine. anything need updating in the doc-string?

have also done the changes to the doc string and added a versionadded or versionchanged tag for 1.4.0

attack68 added 2 commits July 5, 2021 09:20
# Conflicts:
#	doc/source/whatsnew/v1.4.0.rst
# Conflicts:
#	doc/source/whatsnew/v1.4.0.rst
@jreback jreback merged commit f1e4fb0 into pandas-dev:master Jul 9, 2021
@jreback
Copy link
Contributor

jreback commented Jul 9, 2021

thanks @attack68

@attack68 attack68 deleted the styler_bar_fix branch July 9, 2021 18:02
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

Successfully merging this pull request may close these issues.

Pandas style.bar(align='mid') does not make sense.
2 participants