Google News
logo
Pandas - Interview Questions
Explain Categorical Data In Pandas?
Categorical data refers to real-time data that can be repetitive; for instance, data values under categories such as country, gender, codes will always be repetitive. Categorical values in pandas can also take only a limited and fixed number of possible values. 
 
Numerical operations cannot be performed on such data. All values of categorical data in pandas are either in categories or np.nan.
 
This data type can be useful in the following cases :
 
* If a string variable contains only a few different values, converting it into a categorical variable can save some memory.
* It is useful as a signal to other Python libraries because this column must be treated as a categorical variable.
* A lexical order can be converted to a categorical order to be sorted correctly, like a logical order.
Advertisement