How to use is_categorical_dtype method in hypothesis

Best Python code snippet using hypothesis

parsers.pyi

Source:parsers.pyi Github

copy

Full Screen

...178 ...179def is_bool_dtype(arr_or_dtype) -> bool:180 "\n Check whether the provided array or dtype is of a boolean dtype.\n\n Parameters\n ----------\n arr_or_dtype : array-like\n The array or dtype to check.\n\n Returns\n -------\n boolean\n Whether or not the array or dtype is of a boolean dtype.\n\n Notes\n -----\n An ExtensionArray is considered boolean when the ``_is_boolean``\n attribute is set to True.\n\n Examples\n --------\n >>> is_bool_dtype(str)\n False\n >>> is_bool_dtype(int)\n False\n >>> is_bool_dtype(bool)\n True\n >>> is_bool_dtype(np.bool_)\n True\n >>> is_bool_dtype(np.array(['a', 'b']))\n False\n >>> is_bool_dtype(pd.Series([1, 2]))\n False\n >>> is_bool_dtype(np.array([True, False]))\n True\n >>> is_bool_dtype(pd.Categorical([True, False]))\n True\n >>> is_bool_dtype(pd.arrays.SparseArray([True, False]))\n True\n "181 ...182def is_categorical_dtype(arr_or_dtype) -> bool:183 '\n Check whether an array-like or dtype is of the Categorical dtype.\n\n Parameters\n ----------\n arr_or_dtype : array-like\n The array-like or dtype to check.\n\n Returns\n -------\n boolean\n Whether or not the array-like or dtype is of the Categorical dtype.\n\n Examples\n --------\n >>> is_categorical_dtype(object)\n False\n >>> is_categorical_dtype(CategoricalDtype())\n True\n >>> is_categorical_dtype([1, 2, 3])\n False\n >>> is_categorical_dtype(pd.Categorical([1, 2, 3]))\n True\n >>> is_categorical_dtype(pd.CategoricalIndex([1, 2, 3]))\n True\n '184 ...185def is_datetime64_dtype(arr_or_dtype) -> bool:186 '\n Check whether an array-like or dtype is of the datetime64 dtype.\n\n Parameters\n ----------\n arr_or_dtype : array-like\n The array-like or dtype to check.\n\n Returns\n -------\n boolean\n Whether or not the array-like or dtype is of the datetime64 dtype.\n\n Examples\n --------\n >>> is_datetime64_dtype(object)\n False\n >>> is_datetime64_dtype(np.datetime64)\n True\n >>> is_datetime64_dtype(np.array([], dtype=int))\n False\n >>> is_datetime64_dtype(np.array([], dtype=np.datetime64))\n True\n >>> is_datetime64_dtype([1, 2, 3])\n False\n '187 ...188def is_extension_array_dtype(arr_or_dtype) -> bool:189 "\n Check if an object is a pandas extension array type.\n\n See the :ref:`Use Guide <extending.extension-types>` for more.\n\n Parameters\n ----------\n arr_or_dtype : object\n For array-like input, the ``.dtype`` attribute will\n be extracted.\n\n Returns\n -------\n bool\n Whether the `arr_or_dtype` is an extension array type.\n\n Notes\n -----\n This checks whether an object implements the pandas extension\n array interface. In pandas, this includes:\n\n * Categorical\n * Sparse\n * Interval\n * Period\n * DatetimeArray\n * TimedeltaArray\n\n Third-party libraries may implement arrays or types satisfying\n this interface as well.\n\n Examples\n --------\n >>> from pandas.api.types import is_extension_array_dtype\n >>> arr = pd.Categorical(['a', 'b'])\n >>> is_extension_array_dtype(arr)\n True\n >>> is_extension_array_dtype(arr.dtype)\n True\n\n >>> arr = np.array(['a', 'b'])\n >>> is_extension_array_dtype(arr.dtype)\n False\n "190 ...191def is_float_dtype(arr_or_dtype) -> bool:192 "\n Check whether the provided array or dtype is of a float dtype.\n\n This function is internal and should not be exposed in the public API.\n\n Parameters\n ----------\n arr_or_dtype : array-like\n The array or dtype to check.\n\n Returns\n -------\n boolean\n Whether or not the array or dtype is of a float dtype.\n\n Examples\n --------\n >>> is_float_dtype(str)\n False\n >>> is_float_dtype(int)\n False\n >>> is_float_dtype(float)\n True\n >>> is_float_dtype(np.array(['a', 'b']))\n False\n >>> is_float_dtype(pd.Series([1, 2]))\n False\n >>> is_float_dtype(pd.Index([1, 2.]))\n True\n "193 ...194def is_integer_dtype(arr_or_dtype) -> bool:195 "\n Check whether the provided array or dtype is of an integer dtype.\n\n Unlike in `in_any_int_dtype`, timedelta64 instances will return False.\n\n .. versionchanged:: 0.24.0\n\n The nullable Integer dtypes (e.g. pandas.Int64Dtype) are also considered\n as integer by this function.\n\n Parameters\n ----------\n arr_or_dtype : array-like\n The array or dtype to check.\n\n Returns\n -------\n boolean\n Whether or not the array or dtype is of an integer dtype and\n not an instance of timedelta64.\n\n Examples\n --------\n >>> is_integer_dtype(str)\n False\n >>> is_integer_dtype(int)\n True\n >>> is_integer_dtype(float)\n False\n >>> is_integer_dtype(np.uint64)\n True\n >>> is_integer_dtype('int8')\n True\n >>> is_integer_dtype('Int8')\n True\n >>> is_integer_dtype(pd.Int8Dtype)\n True\n >>> is_integer_dtype(np.datetime64)\n False\n >>> is_integer_dtype(np.timedelta64)\n False\n >>> is_integer_dtype(np.array(['a', 'b']))\n False\n >>> is_integer_dtype(pd.Series([1, 2]))\n True\n >>> is_integer_dtype(np.array([], dtype=np.timedelta64))\n False\n >>> is_integer_dtype(pd.Index([1, 2.])) # float\n False\n "196 ...197def is_object_dtype(arr_or_dtype) -> bool:...

Full Screen

Full Screen

table_schema.py

Source:table_schema.py Github

copy

Full Screen

...42 elif (is_datetime64_dtype(x) or is_datetime64tz_dtype(x)):43 return 'datetime'44 elif is_timedelta64_dtype(x):45 return 'duration'46 elif is_categorical_dtype(x):47 return 'any'48 elif is_string_dtype(x):49 return 'string'50 else:51 return 'any'52def set_default_names(data):53 """Sets index names to 'index' for regular, or 'level_x' for Multi"""54 if all(name is not None for name in data.index.names):55 return data56 data = data.copy()57 if data.index.nlevels > 1:58 names = [name if name is not None else 'level_{}'.format(i)59 for i, name in enumerate(data.index.names)]60 data.index.names = names61 else:62 data.index.name = data.index.name or 'index'63 return data64def make_field(arr, dtype=None):65 dtype = dtype or arr.dtype66 if arr.name is None:67 name = 'values'68 else:69 name = arr.name70 field = {'name': name,71 'type': as_json_table_type(dtype)}72 if is_categorical_dtype(arr):73 if hasattr(arr, 'categories'):74 cats = arr.categories75 ordered = arr.ordered76 else:77 cats = arr.cat.categories78 ordered = arr.cat.ordered79 field['constraints'] = {"enum": list(cats)}80 field['ordered'] = ordered81 elif is_datetime64tz_dtype(arr):82 if hasattr(arr, 'dt'):83 field['tz'] = arr.dt.tz.zone84 else:85 field['tz'] = arr.tz.zone86 return field...

Full Screen

Full Screen

api.pyi

Source:api.pyi Github

copy

Full Screen

1from pandas.core.dtypes.common import (2 is_array_like as is_array_like,3 is_bool as is_bool,4 is_bool_dtype as is_bool_dtype,5 is_categorical as is_categorical,6 is_categorical_dtype as is_categorical_dtype,7 is_complex as is_complex,8 is_complex_dtype as is_complex_dtype,9 is_datetime64_any_dtype as is_datetime64_any_dtype,10 is_datetime64_dtype as is_datetime64_dtype,11 is_datetime64_ns_dtype as is_datetime64_ns_dtype,12 is_datetime64tz_dtype as is_datetime64tz_dtype,13 is_dict_like as is_dict_like,14 is_dtype_equal as is_dtype_equal,15 is_extension_array_dtype as is_extension_array_dtype,16 is_extension_type as is_extension_type,17 is_file_like as is_file_like,18 is_float as is_float,19 is_float_dtype as is_float_dtype,20 is_hashable as is_hashable,21 is_int64_dtype as is_int64_dtype,22 is_integer as is_integer,23 is_integer_dtype as is_integer_dtype,24 is_interval as is_interval,25 is_interval_dtype as is_interval_dtype,26 is_iterator as is_iterator,27 is_list_like as is_list_like,28 is_named_tuple as is_named_tuple,29 is_number as is_number,30 is_numeric_dtype as is_numeric_dtype,31 is_object_dtype as is_object_dtype,32 is_period_dtype as is_period_dtype,33 is_re as is_re,34 is_re_compilable as is_re_compilable,35 is_scalar as is_scalar,36 is_signed_integer_dtype as is_signed_integer_dtype,37 is_sparse as is_sparse,38 is_string_dtype as is_string_dtype,39 is_timedelta64_dtype as is_timedelta64_dtype,40 is_timedelta64_ns_dtype as is_timedelta64_ns_dtype,41 is_unsigned_integer_dtype as is_unsigned_integer_dtype,...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run hypothesis automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful