Best Python code snippet using pandera_python
dtypes.py
Source: dtypes.py
...293 return "timedelta"294###############################################################################295# Utilities296###############################################################################297def is_subdtype(298 arg1: Union[DataType, Type[DataType]],299 arg2: Union[DataType, Type[DataType]],300) -> bool:301 """Returns True if first argument is lower/equal in DataType hierarchy."""302 arg1_cls = arg1 if inspect.isclass(arg1) else arg1.__class__303 arg2_cls = arg2 if inspect.isclass(arg2) else arg2.__class__304 return issubclass(arg1_cls, arg2_cls) # type: ignore305def is_int(pandera_dtype: Union[DataType, Type[DataType]]) -> bool:306 """Return True if :class:`pandera.dtypes.DataType` is an integer."""307 return is_subdtype(pandera_dtype, Int)308def is_uint(pandera_dtype: Union[DataType, Type[DataType]]) -> bool:309 """Return True if :class:`pandera.dtypes.DataType` is310 an unsigned integer."""311 return is_subdtype(pandera_dtype, UInt)312def is_float(pandera_dtype: Union[DataType, Type[DataType]]) -> bool:313 """Return True if :class:`pandera.dtypes.DataType` is a float."""314 return is_subdtype(pandera_dtype, Float)315def is_complex(pandera_dtype: Union[DataType, Type[DataType]]) -> bool:316 """Return True if :class:`pandera.dtypes.DataType` is a complex number."""317 return is_subdtype(pandera_dtype, Complex)318def is_numeric(pandera_dtype: Union[DataType, Type[DataType]]) -> bool:319 """Return True if :class:`pandera.dtypes.DataType` is a complex number."""320 return is_subdtype(pandera_dtype, _Number)321def is_bool(pandera_dtype: Union[DataType, Type[DataType]]) -> bool:322 """Return True if :class:`pandera.dtypes.DataType` is a boolean."""323 return is_subdtype(pandera_dtype, Bool)324def is_string(pandera_dtype: Union[DataType, Type[DataType]]) -> bool:325 """Return True if :class:`pandera.dtypes.DataType` is a string."""326 return is_subdtype(pandera_dtype, String)327def is_category(pandera_dtype: Union[DataType, Type[DataType]]) -> bool:328 """Return True if :class:`pandera.dtypes.DataType` is a category."""329 return is_subdtype(pandera_dtype, Category)330def is_datetime(pandera_dtype: Union[DataType, Type[DataType]]) -> bool:331 """Return True if :class:`pandera.dtypes.DataType` is a datetime."""332 return is_subdtype(pandera_dtype, DateTime)333def is_timedelta(pandera_dtype: Union[DataType, Type[DataType]]) -> bool:334 """Return True if :class:`pandera.dtypes.DataType` is a timedelta."""...
utils.py
Source: utils.py
...14 dtype_groups = column_series.groupby(dataframe.dtypes).groups15 if dtype_filter is None:16 dtype_filter = null_filter17 return {k.name: v for k, v in dtype_groups.items() if dtype_filter(k.name)}18def is_subdtype(dtype1, dtype2):19 if isinstance(dtype1, six.string_types):20 try:21 dtype1 = np.dtype(dtype1)22 except TypeError:23 return False24 return np.issubdtype(dtype1, dtype2)25def is_ordinal(dtype):26 return is_subdtype(dtype, np.integer)27def is_continous(dtype):28 return is_subdtype(dtype, np.number) and not is_ordinal(dtype)29def is_numeric(dtype):30 return is_subdtype(dtype, np.number)31def is_categorical(dtype):32 return not is_numeric(dtype)33def ordinal_columns(dataframe):34 return unflatten_list(dtype_dict(dataframe, is_ordinal).values())35def continous_columns(dataframe):36 return unflatten_list(dtype_dict(dataframe, is_continous).values())37def numeric_columns(dataframe):38 return unflatten_list(dtype_dict(dataframe, is_numeric).values())39def categorical_columns(dataframe):40 return unflatten_list(dtype_dict(dataframe, is_categorical).values())41def mean_impute_numerics(dataframe):42 numerics = dataframe.values43 # impute with mean44 imputer = Imputer(strategy='mean', missing_values='NaN')...
test_validators.py
Source: test_validators.py
...56 v = in_bounds((0, 5), closed=closed)57 expected = f"<in_bounds validator with bounds {interval_str}>"58 assert repr(v) == expected59def test_is_subdtype_success(simple_attr):60 v = is_subdtype(np.number)61 # nothing happends62 v(None, simple_attr, np.array([1, 2, 3]))63 v(None, simple_attr, np.array([1.0, 2.0, 3.0]))64def test_is_subdtype_fail(simple_attr):65 v = is_subdtype(np.number)66 with pytest.raises(TypeError, match=r".*not a sub-dtype of.*"):67 v(None, simple_attr, np.array(["1", "2", "3"]))68def test_is_subdtype_repr():69 v = is_subdtype(np.number)...
Check out the latest blogs from LambdaTest on this topic:
I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.
When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.
Pair testing can help you complete your testing tasks faster and with higher quality. But who can do pair testing, and when should it be done? And what form of pair testing is best for your circumstance? Check out this blog for more information on how to conduct pair testing to optimize its benefits.
People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.
Have you ever visited a website that only has plain text and images? Most probably, no. It’s because such websites do not exist now. But there was a time when websites only had plain text and images with almost no styling. For the longest time, websites did not focus on user experience. For instance, this is how eBay’s homepage looked in 1999.
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!!