'TypeError: data type "category" not understood, while looping through the columns in the dataframe
data.info()
DataTypes info of the dataframe
for col in data.columns:
if data[col].dtype == "category":
print(data[col].value_counts())
print("\n\n")
I get the following error
TypeError: data type "category" not understood
Is there any other way to find the same?
Solution 1:[1]
Use select_dtypes:
for col in data.select_dtypes('category'):
print(data[col].value_counts(), end='\n\n')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Corralien |
