Best Python code snippet using pandera_python
pandas_engine.py
Source:pandas_engine.py  
...159    type = pd.BooleanDtype()160###############################################################################161# number162###############################################################################163def _register_numpy_numbers(164    builtin_name: str, pandera_name: str, sizes: List[int]165) -> None:166    """Register pandera.engines.numpy_engine DataTypes167    with the pandas engine."""168    builtin_type = getattr(builtins, builtin_name, None)  # uint doesn't exist169    # default to int64 regardless of OS170    default_pd_dtype = {171        "int": np.dtype("int64"),172        "uint": np.dtype("uint64"),173    }.get(builtin_name, pd.Series([1], dtype=builtin_name).dtype)174    for bit_width in sizes:175        # e.g.: numpy.int64176        np_dtype = getattr(np, f"{builtin_name}{bit_width}")177        equivalents = set(178            (179                np_dtype,180                # e.g.: pandera.dtypes.Int64181                getattr(dtypes, f"{pandera_name}{bit_width}"),182                getattr(dtypes, f"{pandera_name}{bit_width}")(),183            )184        )185        if np_dtype == default_pd_dtype:186            equivalents |= set(187                (188                    default_pd_dtype,189                    builtin_name,190                    getattr(dtypes, pandera_name),191                    getattr(dtypes, pandera_name)(),192                )193            )194            if builtin_type:195                equivalents.add(builtin_type)196            # results from pd.api.types.infer_dtype197            if builtin_type is float:198                equivalents.add("floating")199                equivalents.add("mixed-integer-float")200            elif builtin_type is int:201                equivalents.add("integer")202        numpy_data_type = getattr(numpy_engine, f"{pandera_name}{bit_width}")203        Engine.register_dtype(numpy_data_type, equivalents=list(equivalents))204###############################################################################205# signed integer206###############################################################################207_register_numpy_numbers(208    builtin_name="int",209    pandera_name="Int",210    sizes=[64, 32, 16, 8],211)212@Engine.register_dtype(equivalents=[pd.Int64Dtype, pd.Int64Dtype()])213@immutable214class INT64(DataType, dtypes.Int):215    """Semantic representation of a :class:`pandas.Int64Dtype`."""216    type = pd.Int64Dtype()217    bit_width: int = 64218@Engine.register_dtype(equivalents=[pd.Int32Dtype, pd.Int32Dtype()])219@immutable220class INT32(INT64):221    """Semantic representation of a :class:`pandas.Int32Dtype`."""222    type = pd.Int32Dtype()223    bit_width: int = 32224@Engine.register_dtype(equivalents=[pd.Int16Dtype, pd.Int16Dtype()])225@immutable226class INT16(INT32):227    """Semantic representation of a :class:`pandas.Int16Dtype`."""228    type = pd.Int16Dtype()229    bit_width: int = 16230@Engine.register_dtype(equivalents=[pd.Int8Dtype, pd.Int8Dtype()])231@immutable232class INT8(INT16):233    """Semantic representation of a :class:`pandas.Int8Dtype`."""234    type = pd.Int8Dtype()235    bit_width: int = 8236###############################################################################237# unsigned integer238###############################################################################239_register_numpy_numbers(240    builtin_name="uint",241    pandera_name="UInt",242    sizes=[64, 32, 16, 8],243)244@Engine.register_dtype(equivalents=[pd.UInt64Dtype, pd.UInt64Dtype()])245@immutable246class UINT64(DataType, dtypes.UInt):247    """Semantic representation of a :class:`pandas.UInt64Dtype`."""248    type = pd.UInt64Dtype()249    bit_width: int = 64250@Engine.register_dtype(equivalents=[pd.UInt32Dtype, pd.UInt32Dtype()])251@immutable252class UINT32(UINT64):253    """Semantic representation of a :class:`pandas.UInt32Dtype`."""254    type = pd.UInt32Dtype()255    bit_width: int = 32256@Engine.register_dtype(equivalents=[pd.UInt16Dtype, pd.UInt16Dtype()])257@immutable258class UINT16(UINT32):259    """Semantic representation of a :class:`pandas.UInt16Dtype`."""260    type = pd.UInt16Dtype()261    bit_width: int = 16262@Engine.register_dtype(equivalents=[pd.UInt8Dtype, pd.UInt8Dtype()])263@immutable264class UINT8(UINT16):265    """Semantic representation of a :class:`pandas.UInt8Dtype`."""266    type = pd.UInt8Dtype()267    bit_width: int = 8268# ###############################################################################269# # float270# ###############################################################################271_register_numpy_numbers(272    builtin_name="float",273    pandera_name="Float",274    sizes=[128, 64, 32, 16] if FLOAT_128_AVAILABLE else [64, 32, 16],275)276if PANDAS_1_2_0_PLUS:277    @Engine.register_dtype(equivalents=[pd.Float64Dtype, pd.Float64Dtype()])278    @immutable279    class FLOAT64(DataType, dtypes.Float):280        """Semantic representation of a :class:`pandas.Float64Dtype`."""281        type = pd.Float64Dtype()282        bit_width: int = 64283    @Engine.register_dtype(equivalents=[pd.Float32Dtype, pd.Float32Dtype()])284    @immutable285    class FLOAT32(FLOAT64):286        """Semantic representation of a :class:`pandas.Float32Dtype`."""287        type = pd.Float32Dtype()288        bit_width: int = 32289# ###############################################################################290# # complex291# ###############################################################################292_register_numpy_numbers(293    builtin_name="complex",294    pandera_name="Complex",295    sizes=[256, 128, 64] if FLOAT_128_AVAILABLE else [128, 64],296)297# ###############################################################################298# # nominal299# ###############################################################################300@Engine.register_dtype(301    equivalents=[302        "category",303        "categorical",304        dtypes.Category,305        pd.CategoricalDtype,306    ]...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
