Comments (5)
@amosaikman can you provide a minimally reproducible example? the snippet you provided is a good start, but it needs to be copy-pastable to reproduce.
from pandera.
@cosmicBboy Is this better?
df2 = pd.DataFrame(
{
"sample_id": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"],
"Cu_ppm": [10, 20, -1, 40, 50, 60, 70, 80, 90, 100],
"Cs_ppb": [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],
"spam": [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],
}
)
schema7 = pa.DataFrameSchema(
{
r"^[A-Z][a-z]*_ppm$": pa.Column(
float,
nullable=True,
coerce=True,
checks=pa.Check.in_range(0, 1e6),
required=False,
regex=True,
),
},
index=pa.Index(str, nullable=False, unique=True, coerce=True),
checks=valid_column_labels,
strict='filter',
)
schema7.validate(df2)
For me that produces a DataFrame with a default integer index, one column labelled Cu_ppm
containing the supplied data coerced to float. I expected it to produce a SchemaError
because -1 is outside the in_range
bounds.
from pandera.
what checks are contained in valid_column_labels
?
from pandera.
Sorry, missed that.
valid_column_labels = [
pa.Check(lambda df: df.columns.is_unique, element_wise=False, error="Columns must be unique"),
pa.Check(
lambda df: df.columns.str.split("_").str[0].isin(valid_prefixes).all(),
element_wise=False,
error="Element symbols must be valid",
),
]
valid_prefixes
in this dummy context is just a long list of element symbols e.g. ['H', 'He', …]
from pandera.
#1248 should address this issue
from pandera.
Related Issues (20)
- Should DataFrameModel.validate raise SchemaInitError when using pydantic v2 `model_config`? HOT 2
- Pandera import fails due to DatetimeAccessor issue in Python 3.11.9 HOT 1
- Pandera Series generic argument does not allow the `typing.List` etc. types HOT 3
- no exception raise after pipe on 3.11.9 HOT 1
- How to Avoid Pandera Doc Injection? HOT 5
- Custom check fails with `pl.DataFrame` HOT 3
- Custom check erroneously passes when validating `pl.LazyFrame` HOT 8
- Remove dependencies on `wrapt`, `packaging`, and potentially `multimethod`
- Make `pydantic` and `typeguard` extras for pandas generic type support
- Is there a way to get a `DataFrameModel` from existing `pandas.DataFrame`? HOT 2
- Hypothesis examples are all the same HOT 7
- Parametrized type annotations are broken for polars DataFrameModels HOT 1
- Piping pandas with pandera schema doesn't raise SchemaError ( python 3.11.9 ) HOT 1
- Lazy schema validation does not raise expected errors with polars dataframes HOT 3
- Update branch name mentioned within bug report template HOT 1
- Custom DTypes With Polars HOT 3
- Error Importing Pandera with Polars extra HOT 2
- Add a polars `Series` type HOT 10
- Allow check type HOT 2
- How to load schema from pyspark struct or avro format from schema registry ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pandera.