How to check that a column only contains uppercase letters? #1560
Answered
by
philiporlando
philiporlando
asked this question in
Q&A
-
I'm trying to ensure that a "County" column only contains uppercase characters. import polars as pl
import pandera.polars as pa
df = pl.DataFrame(
{
"County": ["LOS ANGELES", "SAN FRANCISCO", "ALAMEDA"],
}
)
schema = pa.DataFrameSchema(
{
"County": pa.Column(
dtype=str,
checks=[
pa.Check(
lambda s: s.upper() == s,
error="County must be uppercase",
element_wise=True,
),
],
)
}
)
validated_df = schema.validate(df)
print(schema(df)) This appears to be working with this small reprex, but I'm also seeing a warning related to a missing
However, when I try to apply the same check with my production data, I'm seeing the below error:
I'm hoping to learn more about why I'm encountering this error and identify a more reliable way of checking for string casing within polars dataframes. |
Beta Was this translation helpful? Give feedback.
Answered by
philiporlando
Apr 13, 2024
Replies: 1 comment
-
This error was due to a bug that was fixed in #1572. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
philiporlando
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This error was due to a bug that was fixed in #1572.