### Example Validated DataFrame Output Source: https://pandera.readthedocs.io/en/stable?badge=stable This is the output of the validated DataFrame from the Quick Start example. It shows the DataFrame after successful validation against the defined schema. ```text column1 column2 column3 0 1 1.1 a 1 2 1.2 b 2 3 1.3 c ``` -------------------------------- ### example Source: https://pandera.readthedocs.io/en/stable/reference/generated/pandera.api.pandas.components.MultiIndex.html Generate an example of a MultiIndex with a specified size. ```APIDOC ## example ### Description Generate an example of a MultiIndex with a specified size. ### Parameters * **size** – Optional - number of elements in the generated DataFrame. ### Returns `MultiIndex` - pandas DataFrame object. ``` -------------------------------- ### Install pandera with Modin extras Source: https://pandera.readthedocs.io/en/stable/modin.html Install pandera with the necessary extras for Modin integration. Choose the specific backend (ray or dask) or install both. ```bash pip install 'pandera[modin]' ``` ```bash pip install 'pandera[modin-ray]' ``` ```bash pip install 'pandera[modin-dask]' ``` -------------------------------- ### Install Pandera with Strategies Extra Source: https://pandera.readthedocs.io/en/stable/index.html Install pandera with the strategies extra for data synthesis strategies. ```bash pip install 'pandera[strategies]' ``` -------------------------------- ### Install Pandera with FastAPI Extra Source: https://pandera.readthedocs.io/en/stable/index.html Install pandera with the fastapi extra for fastapi integration. ```bash pip install 'pandera[fastapi]' ``` -------------------------------- ### Install Pandera with Frictionless Extra Source: https://pandera.readthedocs.io/en/stable/index.html Install pandera with the frictionless extra for frictionless schema serialization/deserialization. ```bash pip install 'pandera[frictionless]' ``` -------------------------------- ### Install Pandera with Pandas Extra using uv Source: https://pandera.readthedocs.io/en/stable/index.html Install pandera with the pandas extra using uv. ```bash uv pip install 'pandera[pandas]' ``` -------------------------------- ### Install Pandera with Pandas Extra Source: https://pandera.readthedocs.io/en/stable/index.html Install pandera with the pandas extra using pip. ```bash pip install 'pandera[pandas]' ``` -------------------------------- ### Install Pandera with Hypothesis Extra Source: https://pandera.readthedocs.io/en/stable/index.html Install pandera with the hypothesis extra for hypothesis checks. ```bash pip install 'pandera[hypotheses]' ``` -------------------------------- ### Install Pandera with Conda Source: https://pandera.readthedocs.io/en/stable/index.html Install pandera with conda. ```bash conda install -c conda-forge pandera-pandas ``` -------------------------------- ### Index.example Source: https://pandera.readthedocs.io/en/stable/reference/generated/pandera.api.pandas.components.Index.html Generate an example of a particular size. ```APIDOC ## example ### Description Generate an example of a particular size. ### Parameters #### Parameters - **size** (UnionType[int, None]) – number of elements in the generated Index. ### Returns `Index` - pandas Index object. ``` -------------------------------- ### Install Conda Packages for Extras Source: https://pandera.readthedocs.io/en/stable/index.html Install various pandera extras using conda. ```bash conda install -c conda-forge pandera-hypotheses # hypothesis checks conda install -c conda-forge pandera-io # yaml/script schema io utilities conda install -c conda-forge pandera-frictionless # frictionless schema serialization/deserialization conda install -c conda-forge pandera-strategies # data synthesis strategies conda install -c conda-forge pandera-mypy # enable static type-linting of pandas conda install -c conda-forge pandera-fastapi # fastapi integration conda install -c conda-forge pandera-dask # validate dask dataframes conda install -c conda-forge pandera-pyspark # validate pyspark dataframes conda install -c conda-forge pandera-modin # validate modin dataframes conda install -c conda-forge pandera-modin-ray # validate modin dataframes with ray conda install -c conda-forge pandera-modin-dask # validate modin dataframes with dask conda install -c conda-forge pandera-geopandas # validate geopandas geodataframes conda install -c conda-forge pandera-polars # validate polars dataframes conda install -c conda-forge pandera-ibis # validate ibis tables ``` -------------------------------- ### Install Pandera with Ibis Extra Source: https://pandera.readthedocs.io/en/stable/index.html Install pandera with the ibis extra to validate ibis tables. ```bash pip install 'pandera[ibis]' ``` -------------------------------- ### Install Pandera with IO Extra Source: https://pandera.readthedocs.io/en/stable/index.html Install pandera with the io extra for yaml/script schema io utilities. ```bash pip install 'pandera[io]' ``` -------------------------------- ### Install Pandera with Ibis and an Ibis backend Source: https://pandera.readthedocs.io/en/stable/ibis.html Install pandera with the ibis extra and the desired Ibis backend, such as duckdb. ```bash pip install 'pandera[ibis]' 'ibis-framework[duckdb]' ``` -------------------------------- ### Pandera Check Examples Source: https://pandera.readthedocs.io/en/stable/reference/generated/pandera.api.checks.Check.html Demonstrates various ways to define and use pandera Checks for data validation, including vectorized, element-wise, group-based, and DataFrame-level checks. This example requires pandas and pandera to be installed. ```python import pandas as pd import pandera.pandas as pa # column checks are vectorized by default check_positive = pa.Check(lambda s: s > 0) # define an element-wise check check_even = pa.Check(lambda x: x % 2 == 0, element_wise=True) # checks can be given human-readable metadata check_with_metadata = pa.Check( lambda x: True, title="Always passes", description="This check always passes." ) # specify assertions across categorical variables using `groupby`, # for example, make sure the mean measure for group "A" is always # larger than the mean measure for group "B" check_by_group = pa.Check( lambda measures: measures["A"].mean() > measures["B"].mean(), groupby=["group"], ) # define a wide DataFrame-level check check_dataframe = pa.Check( lambda df: df["measure_1"] > df["measure_2"]) measure_checks = [check_positive, check_even, check_by_group] schema = pa.DataFrameSchema( columns={ "measure_1": pa.Column(int, checks=measure_checks), "measure_2": pa.Column(int, checks=measure_checks), "group": pa.Column(str), }, checks=check_dataframe ) df = pd.DataFrame({ "measure_1": [10, 12, 14, 16], "measure_2": [2, 4, 6, 8], "group": ["B", "B", "A", "A"] }) schema.validate(df)[["measure_1", "measure_2", "group"]] ``` -------------------------------- ### Generate Example DataFrame from Schema Source: https://pandera.readthedocs.io/en/stable/data_synthesis_strategies.html Use the `example` method on a pandera DataFrameSchema to generate a DataFrame of a specified size. This is useful for interactive exploration and documentation. ```python import pandera.pandas as pa schema = pa.DataFrameSchema( { "column1": pa.Column(int, pa.Check.eq(10)), "column2": pa.Column(float, pa.Check.eq(0.25)), "column3": pa.Column(str, pa.Check.eq("foo")), } ) schema.example(size=3) ``` -------------------------------- ### Install Pandera with Mypy support Source: https://pandera.readthedocs.io/en/stable/mypy_integration.html Install the pandera package with the 'mypy' extra to enable Mypy integration. ```bash pip install pandera[mypy] ``` -------------------------------- ### Install Fugue with Spark Support Source: https://pandera.readthedocs.io/en/stable/fugue.html Install Fugue with the 'spark' extra to include PySpark. Use the 'dask' extra for Dask support. ```bash pip install 'fugue[spark]' ``` -------------------------------- ### Set Up Development Environment with uv Source: https://pandera.readthedocs.io/en/stable/CONTRIBUTING.html Install uv, create a virtual environment, sync dependencies, and activate the environment. This ensures a clean environment for development. ```bash pip install uv uv venv uv sync --all-extras source .venv/bin/activate ``` -------------------------------- ### example Source: https://pandera.readthedocs.io/en/stable/reference/generated/pandera.api.pandas.container.DataFrameSchema.html Generates an example pandas DataFrame based on the schema definition, with a specified number of rows. ```APIDOC ## example ### Description Generates an example pandas DataFrame based on the schema definition, with a specified number of rows. ### Parameters * **size** (UnionType[int, None]) – number of elements in the generated DataFrame. * **n_regex_columns** (int) – number of regex columns to generate. ### Returns `DataFrame` - pandas DataFrame object. ``` -------------------------------- ### Install Pandera Strategies with Conda Source: https://pandera.readthedocs.io/en/stable?badge=latest Install pandera with the strategies extra for data synthesis using conda. ```bash conda install -c conda-forge pandera-strategies ``` -------------------------------- ### Install Pandera with Modin-Ray Extra Source: https://pandera.readthedocs.io/en/stable/index.html Install pandera with the modin-ray extra to validate modin dataframes with ray. ```bash pip install 'pandera[modin-ray]' ``` -------------------------------- ### Install pandera with GeoPandas extra Source: https://pandera.readthedocs.io/en/stable/geopandas.html Install pandera with the geopandas extra to enable GeoPandas support. ```bash pip install 'pandera[geopandas]' ``` -------------------------------- ### Install pandera with PySpark extra Source: https://pandera.readthedocs.io/en/stable/pyspark.html Install pandera with the necessary PySpark extra to enable pyspark.pandas integration. ```bash pip install 'pandera[pyspark]' ``` -------------------------------- ### example() Source: https://pandera.readthedocs.io/en/stable/reference/generated/pandera.api.geopandas.container.GeoDataFrameSchema.html Generates an example GeoDataFrame based on the schema. This class method is similar to `DataFrameSchema.example()` but specifically returns a `GeoDataFrame`. ```APIDOC ## example() ### Description Like `DataFrameSchema.example()`, but returns a `GeoDataFrame` when applicable. ### Parameters * **size** (_int_, optional) – The number of rows to generate. * **n_regex_columns** (_int_, optional) – The number of regex-generated columns. ### Return Type `DataFrame` ``` -------------------------------- ### Install Pandera with Modin Extra Source: https://pandera.readthedocs.io/en/stable/index.html Install pandera with the modin extra to validate modin dataframes. ```bash pip install 'pandera[modin]' ``` -------------------------------- ### Install Pandera with Polars Extra Source: https://pandera.readthedocs.io/en/stable/index.html Install pandera with the polars extra to validate polars dataframes. ```bash pip install 'pandera[polars]' ``` -------------------------------- ### GeoDataFrameModel.example() Source: https://pandera.readthedocs.io/en/stable/reference/generated/pandera.geopandas.GeoDataFrameModel.html Generate an example of this data model specification. ```APIDOC ## GeoDataFrameModel.example() ### Description Generate an example of this data model specification. ### Return Type GeoDataFrameT[Self] ``` -------------------------------- ### Install Pandera with Xarray Extra Source: https://pandera.readthedocs.io/en/stable/index.html Install pandera with the xarray extra to validate xarray data structures. ```bash pip install 'pandera[xarray]' ``` -------------------------------- ### Generate Example Index Data Source: https://pandera.readthedocs.io/en/stable/reference/generated/pandera.api.pandas.components.Index.html The `example` method generates a sample pandas Index object based on the schema definition. This is useful for testing and demonstration purposes. ```python import pandera as pa # Define an Index schema index_schema = pa.Index(dtype="int64", name="id") # Generate an example Index with 5 elements example_index = index_schema.example(size=5) print(example_index) ``` -------------------------------- ### Install Pandera with Modin-Dask Extra Source: https://pandera.readthedocs.io/en/stable/index.html Install pandera with the modin-dask extra to validate modin dataframes with dask. ```bash pip install 'pandera[modin-dask]' ``` -------------------------------- ### Install pandera with Dask extra Source: https://pandera.readthedocs.io/en/stable/dask.html Install pandera with the necessary Dask extra to enable Dask DataFrame validation. ```bash pip install 'pandera[dask]' ``` -------------------------------- ### Pandera DataFrame Type Checking Examples Source: https://pandera.readthedocs.io/en/stable/mypy_integration.html Demonstrates various ways to type hint and check pandas DataFrames using Pandera's DataFrame types and mypy. Includes examples of DataFrame assignment, piping, casting, in-place mutation, and slicing. ```python def fn_pipe_dataframe(df: DataFrame[Schema]) -> DataFrame[SchemaOut]: return df.assign(age=30).pipe(DataFrame[SchemaOut]) # mypy okay def fn_cast_dataframe(df: DataFrame[Schema]) -> DataFrame[SchemaOut]: return cast(DataFrame[SchemaOut], df.assign(age=30)) # mypy okay @pa.check_types def fn_mutate_inplace(df: DataFrame[Schema]) -> DataFrame[SchemaOut]: out = df.assign(age=30).pipe(DataFrame[SchemaOut]) out.drop(columns="age", inplace=True) return out # okay for mypy, pandera raises error @pa.check_types def fn_assign_and_get_index(df: DataFrame[Schema]) -> DataFrame[SchemaOut]: return df.assign(foo=30).iloc[:3] # mypy error ``` -------------------------------- ### Dimension Validation Examples Source: https://pandera.readthedocs.io/en/stable/xarray_guide/data_array_schema.html Shows how to enforce dimension names in order, using None as a wildcard. ```python pa.DataArraySchema(dims=("x", "y")).validate(da) pa.DataArraySchema(dims=("x", None)).validate(da) ``` -------------------------------- ### DataFrameModel.example Source: https://pandera.readthedocs.io/en/stable/reference/generated/pandera.api.dataframe.model.DataFrameModel.html Class method to generate an example of this data model specification. ```APIDOC ## DataFrameModel.example ### Description Generate an example of this data model specification. ### Method `example` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **kwargs** - Keyword arguments for generating the example. ### Returns * `DataFrameBase[Self]` - An example DataFrame instance. ``` -------------------------------- ### Example DataArray Coordinates Source: https://pandera.readthedocs.io/en/stable/xarray_guide/data_models.html Demonstrates the structure and values of coordinates for a DataArray, specifically 'lat' and 'lon'. ```python import numpy as np lat = np.arange(-90, 90, 1) lon = np.arange(-180, 180, 1) print(lat) print(lon) ``` -------------------------------- ### SeriesSchema.example Source: https://pandera.readthedocs.io/en/stable/reference/generated/pandera.api.pandas.array.SeriesSchema.html Generates an example pandas Series based on the schema configuration. ```APIDOC ## SeriesSchema.example ### Description Generates an example pandas Series based on the schema configuration. ### Method example ### Parameters #### Parameters - **size** (None) – number of elements in the generated Series. - **n_regex_columns** (int) – number of regex columns. ### Returns - **Series** – pandas Series object. ``` -------------------------------- ### str_startswith_strategy Source: https://pandera.readthedocs.io/en/stable/reference/generated/pandera.strategies.pandas_strategies.html Generates strings that start with a specific string pattern. It supports chaining an optional hypothesis strategy and requires a string pattern. ```APIDOC ## str_startswith_strategy ### Description Strategy to generate strings that start with a specific string pattern. ### Method Not applicable (Python function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **pandera_dtype** (`Union[DataType, DataType]`): `pandera.dtypes.DataType` instance. * **strategy** (`UnionType[SearchStrategy, None]`): An optional hypothesis strategy. If specified, the pandas dtype strategy will be chained onto this strategy. * **string** (`str`): String pattern. ### Return Type `SearchStrategy` ### Returns `hypothesis` strategy ``` -------------------------------- ### Column.example Source: https://pandera.readthedocs.io/en/stable/reference/generated/pandera.api.pandas.components.Column.html Generates an example pandas DataFrame based on the column's schema definition. ```APIDOC ## Column.example ### Description Generate an example of a particular size. ### Parameters - **size** - number of elements in the generated Index. ### Returns - **DataFrame** - pandas DataFrame object. ``` -------------------------------- ### Install Pandera Mypy with Conda Source: https://pandera.readthedocs.io/en/stable?badge=latest Install pandera with the mypy extra to enable static type-linting of pandas using conda. ```bash conda install -c conda-forge pandera-mypy ``` -------------------------------- ### Xarray DataArray Example Source: https://pandera.readthedocs.io/en/stable/xarray_guide/checks_and_parsers.html Illustrates an xarray DataArray with coordinate and attribute information. ```python array([-90., -45., 0., 45., 90.]) ``` * lon (lon) float64 -180.0 -140.0 ... 140.0 180.0 ``` array([-180., -140., -100., -60., -20., 20., 60., 100., 140., 180.]) ``` * Attributes: (1) units : K ``` -------------------------------- ### Update Dependencies from environment.yml Source: https://pandera.readthedocs.io/en/stable/CONTRIBUTING.html After altering the environment.yml file, run this command to sync dependencies to requirements.in. This allows installation via various package managers. ```bash make deps-from-environment.yml ``` -------------------------------- ### Attribute Validation with Regex Matching Source: https://pandera.readthedocs.io/en/stable/xarray_guide/data_array_schema.html Use regex patterns (strings starting with `^`) to validate attributes against a set of acceptable string formats. This example checks if the 'units' attribute matches 'K', 'degC', or 'degF'. ```python schema = pa.DataArraySchema( attrs={"units": "^(K|degC|degF)$"}, ) da_units = xr.DataArray( np.ones(3), dims="x", attrs={"units": "K"}, ) schema.validate(da_units) ``` ```python da_bad_units = xr.DataArray( np.ones(3), dims="x", attrs={"units": "meters"}, ) try: schema.validate(da_bad_units) except pa.errors.SchemaError as exc: print(exc) ``` -------------------------------- ### Build Documentation Locally Source: https://pandera.readthedocs.io/en/stable/CONTRIBUTING.html Generate the project documentation locally using the make command. ```bash make docs ``` -------------------------------- ### Example xarray DataArray Source: https://pandera.readthedocs.io/en/stable/xarray_guide/data_models.html An example of an xarray DataArray with 'time', 'lat', and 'lon' dimensions. ```python Size: 6MB array([[[0.35224495, 0.23552507, 0.63530509, ..., 0.76696362, 0.97695049, 0.89224131], [0.34417641, 0.6937307 , 0.55053635, ..., 0.62351941, 0.68943517, 0.15898996], [0.00881282, 0.36015046, 0.52026644, ..., 0.51664449, 0.10939061, 0.5992464 ], ..., [0.21210989, 0.70888113, 0.228842 , ..., 0.79548489, 0.37966265, 0.70009388], [0.53539493, 0.27784502, 0.24944345, ..., 0.60562998, 0.49654642, 0.34689236], [0.03853143, 0.02251944, 0.05700839, ..., 0.32623916, 0.04017552, 0.55345834]], [[0.02220131, 0.12903081, 0.09939153, ..., 0.40078427, 0.56776874, 0.40315637], [0.81293854, 0.23750217, 0.69141051, ..., 0.85707867, 0.04011184, 0.74961657], [0.61291613, 0.11989162, 0.62211809, ..., 0.16181147, 0.84414111, 0.1938169 ], ... [0.20391682, 0.23525606, 0.19058816, ..., 0.58629692, 0.42659518, 0.52615988], [0.24972305, 0.311079 , 0.12511614, ..., 0.05860058, 0.77585309, 0.27618591], [0.19959069, 0.79446702, 0.96490449, ..., 0.79918381, 0.29729941, 0.7445726 ]], [[0.91290466, 0.477176 , 0.2061919 , ..., 0.46593372, 0.82592097, 0.81686105], [0.2843371 , 0.30830673, 0.5066703 , ..., 0.81571164, 0.66502282, 0.45998696], [0.16127676, 0.02425449, 0.66446733, ..., 0.27367376, 0.47944898, 0.63683746], ..., [0.97711755, 0.27625387, 0.79861479, ..., 0.10849807, 0.88675392, 0.95296324], [0.42010144, 0.45662967, 0.70933448, ..., 0.43936467, 0.85807251, 0.53692625], [0.08814553, 0.5614379 , 0.25692175, ..., 0.10044977, 0.0480612 , 0.3867672 ]]], shape=(12, 180, 360)) Coordinates: * time (time) float64 96B 0.0 1.0 2.0 3.0 4.0 ... 7.0 8.0 9.0 10.0 11.0 * lat (lat) float64 1kB -89.5 -88.5 -87.5 -86.5 ... 86.5 87.5 88.5 89.5 * lon (lon) float64 3kB -179.5 -178.5 -177.5 -176.5 ... 177.5 178.5 179.5 ``` -------------------------------- ### Enable Mypy Plugin Source: https://pandera.readthedocs.io/en/stable/mypy_integration.html Configure your mypy.ini or setup.cfg file to use the pandera Mypy plugin. ```ini [mypy] plugins = pandera.mypy ``` -------------------------------- ### Install Pandera Modin with Conda Source: https://pandera.readthedocs.io/en/stable?badge=latest Install pandera with the modin extra to validate modin dataframes using conda. ```bash conda install -c conda-forge pandera-modin ``` -------------------------------- ### Install Pandera PySpark with Conda Source: https://pandera.readthedocs.io/en/stable?badge=latest Install pandera with the pyspark extra to validate pyspark dataframes using conda. ```bash conda install -c conda-forge pandera-pyspark ``` -------------------------------- ### Object.__init__() Source: https://pandera.readthedocs.io/en/stable/reference/generated/pandera.engines.numpy_engine.Object.html Initializes the Object class. ```APIDOC ## Object.__init__() ### Description Initializes the Object class. ### Method __init__ ``` -------------------------------- ### Install Pandera Modin-Ray with Conda Source: https://pandera.readthedocs.io/en/stable?badge=latest Install pandera with the modin-ray extra to validate modin dataframes with ray using conda. ```bash conda install -c conda-forge pandera-modin-ray ``` -------------------------------- ### ArrowFloat16.__init__() Source: https://pandera.readthedocs.io/en/stable/reference/generated/pandera.engines.pandas_engine.ArrowFloat16.html Initializes the ArrowFloat16 object. ```APIDOC ## ArrowFloat16.__init__() ### Description Initializes the ArrowFloat16 object. ### Method __init__ ``` -------------------------------- ### PythonDict.__init__ Source: https://pandera.readthedocs.io/en/stable/reference/generated/pandera.engines.pandas_engine.PythonDict.html Initializes the PythonDict class. ```APIDOC ## Method: PythonDict.__init__ ### Description Initializes the PythonDict class. ### Parameters - `_generic_type` (any, optional): The generic type to associate with the PythonDict instance. ``` -------------------------------- ### Int64.__init__() Source: https://pandera.readthedocs.io/en/stable/reference/generated/pandera.engines.polars_engine.Int64.html Initializes the Int64 data type. ```APIDOC ## Int64.__init__() Initializes the Int64 data type. ``` -------------------------------- ### DataFrameSchema.example Source: https://pandera.readthedocs.io/en/stable/reference/generated/pandera.api.polars.container.DataFrameSchema.html Generates an example Polars DataFrame based on the schema definition. ```APIDOC ## DataFrameSchema.example ### Description Generate an example of a particular size. ### Parameters * **size** (UnionType[int, None]) - Number of elements in the generated DataFrame. * **n_regex_columns** (int) - Number of regex columns to generate. Defaults to 1. ### Returns * pandas DataFrame object. ### Warning This method is not implemented in the Polars backend. ``` -------------------------------- ### List Available Nox Test Configurations Source: https://pandera.readthedocs.io/en/stable/CONTRIBUTING.html View all available test configurations and their parameters using the nox --list command. This helps in selecting specific test environments. ```bash nox --list ``` -------------------------------- ### Generated Python Schema Script Source: https://pandera.readthedocs.io/en/stable/schema_inference.html This is an example of a pandera DataFrameSchema serialized into a Python script. ```python from pandas import Timestamp from pandera import DataFrameSchema, Column, Check, Index, MultiIndex schema = DataFrameSchema( columns={ "column1": Column( dtype="int64", checks=[ Check.greater_than_or_equal_to( min_value=5.0, raise_warning=False, ignore_na=True ), Check.less_than_or_equal_to( max_value=20.0, raise_warning=False, ignore_na=True ), ], ), "column2": Column(dtype="object"), "column3": Column( dtype="datetime64[ns]", checks=[ Check.greater_than_or_equal_to( min_value=Timestamp("2010-01-01 00:00:00"), raise_warning=False, ignore_na=True, ), Check.less_than_or_equal_to( max_value=Timestamp("2012-01-01 00:00:00"), raise_warning=False, ignore_na=True, ), ], ), }, index=Index( dtype="int64", checks=[ Check.greater_than_or_equal_to( min_value=0.0, raise_warning=False, ignore_na=True ), Check.less_than_or_equal_to( max_value=2.0, raise_warning=False, ignore_na=True ), ], nullable=False, coerce=False, name=None, description=None, title=None, ), coerce=True, ) ``` -------------------------------- ### Check.str_startswith Source: https://pandera.readthedocs.io/en/stable/reference/generated/pandera.api.checks.Check.html Verifies that all string values in a series begin with a specified prefix. This is useful for validating string formats. ```APIDOC ## Check.str_startswith ### Description Ensure that all values start with a certain string. ### Method classmethod ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **string** (`str`) – String all values should start with * **kwargs** - key-word arguments passed into the Check initializer. ### Return Type `Check` ``` -------------------------------- ### PydanticModel.__init__ Source: https://pandera.readthedocs.io/en/stable/reference/generated/pandera.engines.pandas_engine.PydanticModel.html Initializes the PydanticModel with a given pydantic model. ```APIDOC ## PydanticModel.__init__() ### Description Initializes the PydanticModel with a given pydantic model. ### Method __init__ ### Parameters * **_model_**: The pydantic model to use. ``` -------------------------------- ### get_regex_columns Source: https://pandera.readthedocs.io/en/stable/reference/generated/pandera.api.pyspark.components.Column.html Get matching column names based on a regex column name pattern. ```APIDOC ## get_regex_columns ### Description Get matching column names based on a regex column name pattern. ### Parameters #### Parameters - **columns** – columns to regex pattern match ### Return Type Iterable ### Returns matching columns ``` -------------------------------- ### DataFrame Model Validation Error Output Source: https://pandera.readthedocs.io/en/stable/dataframe_models.html Example of the error message produced when a DataFrame fails validation against a pandera schema. ```text Column 'year' failed element-wise validator number 0: greater_than(2000) failure cases: 1999 ``` -------------------------------- ### Column.set_name Source: https://pandera.readthedocs.io/en/stable/reference/generated/pandera.api.polars.components.Column.html Sets the name of the schema. If the provided name is a regex starting with '^' and ending with '$', the regex attribute is set to True. ```APIDOC ## Column.set_name ### Description Set the name of the schema. If the name is a regex starting with ‘^’ and ending with ‘$’ set the regex attribute to True. ### Method `set_name` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **name** (`str`) - The name to set for the schema. Can be a literal string or a regex pattern. ### Request Example ```python # Example usage column_with_name = column_object.set_name("my_column") column_with_regex = column_object.set_name("^my_regex_.*$") ``` ### Response #### Success Response (200) Returns the modified Column object. #### Response Example ```python # Returns the Column object with the updated name attribute. ``` ``` -------------------------------- ### Import pandera.geopandas Source: https://pandera.readthedocs.io/en/stable/geopandas.html Import pandera.geopandas as a single entry point for all GeoPandas-related pandera functionalities. ```python import pandera.geopandas as pg ``` -------------------------------- ### Dtype Validation Examples Source: https://pandera.readthedocs.io/en/stable/xarray_guide/data_array_schema.html Demonstrates validating a DataArray's dtype using Python types, NumPy dtypes, and string aliases. ```python da_float32 = xr.DataArray(np.zeros(3, dtype=np.float32), dims="x") pa.DataArraySchema(dtype=float).validate(da) pa.DataArraySchema(dtype=np.float32).validate(da_float32) pa.DataArraySchema(dtype="float32").validate(da_float32) ``` -------------------------------- ### Complex64.__init__() Source: https://pandera.readthedocs.io/en/stable/reference/generated/pandera.dtypes.Complex64.html Initializes the Complex64 data type. ```APIDOC ## Complex64.__init__() ### Description Initializes the Complex64 data type. ### Method __init__ ``` -------------------------------- ### Validate Dataset with CF Standard Names Source: https://pandera.readthedocs.io/en/stable/xarray_guide/cf_conventions.html Validates if a dataset contains specified CF standard names for its variables. Requires cf_xarray to be installed. ```python import xarray as xr import pandera as pa import numpy as np # Ensure cf_xarray is installed: pip install cf_xarray import cf_xarray # noqa: F401 ds = xr.Dataset({ "T": (("x",), np.ones(3), {"standard_name": "air_temperature"}), "P": (("x",), np.ones(3), {"standard_name": "air_pressure"}), }) schema = pa.DatasetSchema( checks=pa.Check.cf_has_standard_names( ("air_temperature", "air_pressure"), ), ) schema.validate(ds) ``` -------------------------------- ### Pandera Column Checks with Groupby Source: https://pandera.readthedocs.io/en/stable/checks.html Demonstrates using `groupby` with single columns, multiple columns, and a callable function for complex grouping logic in Pandera column checks. Ensure necessary imports are present. ```python import pandas as pd import pandera.pandas as pa schema = pa.DataFrameSchema({ "height_in_feet": pa.Column( float, [ # groupby as a single column pa.Check( lambda g: g[False].mean() > 6, groupby="age_less_than_20"), # define multiple groupby columns pa.Check( lambda g: g[(True, "F")].sum() == 9.1, groupby=["age_less_than_20", "sex"]), # groupby as a callable with signature: # (DataFrame) -> DataFrameGroupBy pa.Check( lambda g: g[(False, "M")].median() == 6.75, groupby=lambda df: ( df.assign(age_less_than_15=lambda d: d["age"] < 15) .groupby(["age_less_than_15", "sex"]))) ]), "age": pa.Column(int, pa.Check(lambda s: s > 0)), "age_less_than_20": pa.Column(bool), "sex": pa.Column(str, pa.Check(lambda s: s.isin(["M", "F"]))) }) df = ( pd.DataFrame({ "height_in_feet": [6.5, 7, 6.1, 5.1, 4], "age": [25, 30, 21, 18, 13], "sex": ["M", "M", "F", "F", "F"] }) .assign(age_less_than_20=lambda x: x["age"] < 20) ) schema.validate(df) ``` -------------------------------- ### Define and Validate Dataset with Dimension and Size Constraints Source: https://pandera.readthedocs.io/en/stable/xarray_guide/dataset_schema.html Demonstrates how to use pandera's DatasetSchema to enforce overall dataset dimensions ('x', 'y') and their sizes (x=3, y=4), independent of individual data variable specifications. ```python schema = pa.DatasetSchema( data_vars={ "temperature": pa.DataVar(dtype=float, dims=("x", "y")), }, dims=("x", "y"), sizes={"x": 3, "y": 4}, ) ds_sized = xr.Dataset( {"temperature": (("x", "y"), np.random.rand(3, 4))}, ) schema.validate(ds_sized) ``` -------------------------------- ### Example Data Array with Longitude Source: https://pandera.readthedocs.io/en/stable/xarray_guide/data_models.html Demonstrates a sample DataArray representing longitude coordinates. This is a common data structure used in geospatial analysis. ```python import numpy as np import xarray as xr lon = np.arange(-179.5, 180, 1) data = np.random.rand(360) data_array = xr.DataArray(data, coords=[lon], dims=['lon']) print(data_array) ```