Such variables take a fixed and limited number of possible values. For example, classes, gender, blood type, etc. Also, in the case of categorical variables, the logical order does not match the categorical data, for example, “one”, “two”, “three”. But the sorting of these variables uses a logical order. For example, gender is a categorical variable and has categories — male and female, and there is no internal order in the categories. A purely categorical variable — it is a variable that allows you to simply assign categories, but you cannot clearly order the variables.
Terms related to volatility metrics:
Data = ["Car", "Bat", "Bat", "Car", " Bat "," Bat "," Bat "," Bike "] Mode =" Bat "
 & gt; Multiply each outcome by its probability of occurring.  & gt; Sum these values
Thus, the sum of the values multiplied by the probability of their occurrence is often used to sum the levels of variable factors.
Library downloads —
import
matplotlib.pyplot as plt
import
numpy as np
Data —
Indexing data —


Exit :
Total Labels: 6 Indexing: [0 1 2 3 4 5]
Histogram —

Exit:

Output: