Skip to content

BUG: Compatibility Issues of Numpy Methods with pd.NA in Styler.bar #56425

Open
@ccccjone

Description

@ccccjone

In PR #56341 , we've identified a compatibility issue in Styler.bar where numpy methods fail to properly handle pd.NA.

Related comment as below:
Then the next question is what are the other uses of values. In the code below you will observe the function np.nanmean(values). Does this mean your fix will not work when align="mean"? Or if align is callable?
values is also used when there is a cmap.

Originally posted by @attack68 in #56341 (review)

To demonstrate the problem, I have prepared a code snippet and screenshots showing the error caused by align='mean'. I believe a detailed examination of the compatibility of numpy methods with pd.NA in Styler.bar is needed.

import pandas as pd
df = pd.DataFrame({"A":[1, 2, pd.NA, 4]})
df.style.bar(subset="A", align="mean")
Screen Shot 2023-12-09 at 03 01 53

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions