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

uint dtypes not being classified as scalar values by _str_detect #571

Open
2 tasks done
e-miz opened this issue Dec 20, 2024 · 0 comments · May be fixed by #577
Open
2 tasks done

uint dtypes not being classified as scalar values by _str_detect #571

e-miz opened this issue Dec 20, 2024 · 0 comments · May be fixed by #577

Comments

@e-miz
Copy link

e-miz commented Dec 20, 2024

Prework

Description

Hi! I wanted to make a nanoplot using a column in a dataframe. I found that columns with uint datatypes incorrectly fail a check for being scalar datatypes, which breaks nanoplot functionality for them.

Reproducible example

Works

single_vals_df = pl.DataFrame(
    {
        "bars": [1, 2, 3, 5],
    }
)
single_vals_df.select("bars").cast(pl.Int32).style.fmt_nanoplot(columns="bars", plot_type="bar")

Does Not Work

single_vals_df = pl.DataFrame(
    {
        "bars": [1, 2, 3, 5],
    }
)
single_vals_df.select("bars").cast(pl.UInt32).style.fmt_nanoplot(columns="bars", plot_type="bar")

This leads to an error TypeError: 'NoneType' object is not iterable

Expected result

The example with a UInt32 column should've been able to create nanoplot just like the working example. The values aren't any different, just the datatype.

Development environment

  • Operating System: WSL2 Ubuntu 22.04 LTS
  • great_tables Version: 0.15.0

Additional context

I think I isolated the cause to this line.

_str_detect uses re.match, which fails to match "int" with "uint" because it checks for a match at the beginning. Replacing with re.search fixes the problem because it looks for the pattern anywhere in the target, instead of just the beginning. I don't know if this has repercussions elsewhere though.

P.S. Thanks for the cool library! 😄

@jrycw jrycw linked a pull request Jan 9, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant