Skip to content

BUG: no apply to empty df in Styler #45383

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 3 commits into from
Jan 17, 2022

Conversation

attack68
Copy link
Contributor

@attack68 attack68 commented Jan 15, 2022

@aberres
Copy link
Contributor

aberres commented Jan 16, 2022

Can confirm this fixes a 1.4 regression we are triggering with our code base.

@jreback jreback added this to the 1.4 milestone Jan 16, 2022
@jreback jreback added the Styler conditional formatting using DataFrame.style label Jan 16, 2022
@@ -1486,6 +1486,8 @@ def _apply(
subset = slice(None) if subset is None else subset
subset = non_reducing_slice(subset)
data = self.data.loc[subset]
if data.empty:
return self # don't use DataFrame.apply on empty df
Copy link
Contributor

Choose a reason for hiding this comment

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

comment is not needed but this should probably be a .copy()

@jreback jreback removed this from the 1.4 milestone Jan 16, 2022
@jreback jreback added this to the 1.5 milestone Jan 16, 2022
@attack68 attack68 merged commit d19a31e into pandas-dev:main Jan 17, 2022
@attack68 attack68 deleted the styler_empty_apply branch January 17, 2022 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Styler conditional formatting using DataFrame.style
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Misleading error message when incorrectly using DataFrame.style.apply
3 participants