![]() |
pandas.Categorical(val, categories = None, ordered = None, dtype = None) : It represents a categorical variable. Categorical are a pandas data type that corresponds to the categorical variables in statistics. Such variables take on a fixed and limited number of possible values. For examples – grades, gender, blood group type etc. Parameters- val : [list-like] The values of categorical. categories : [index like] Unique categorisation of the categories. ordered : [boolean] If false, then the categorical is treated as unordered. dtype : [CategoricalDtype] an instance. Error- ValueError : If the categories do not validate. TypeError : If an explicit ordered = True but categorical can't be sorted. Return- Categorical variable Code: Python3
Output : Python3
Output : Python3
Output : Python3
Output :
|
Reffered: https://www.geeksforgeeks.org
Python |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 9 |