As a part of my explanatory data analysis I would like to run a script which checks all columns in my data frame to find the out the variables in which the proportion of number of unique values to the count of values is less than 25%. This behaviour will enable me to find categorical variables even their data type is numeric.
treshold_for_category = 0.25
mostly_cat = {}
category_column_list = list()
for var in df.columns:
mostly_cat[var] = 1.*df[var].nunique()/df[var].count() <
treshold_for_category
for key, value in mostly_cat.items():
if value:
category_column_list.append(key)
After running the code I'm getting the following error:
invalid value encountered in true_divide
unhashable type: 'list'
Could you please support me to fix the issue?
question from:
https://stackoverflow.com/questions/65929459/invalid-value-encountered-in-true-divide-and-unhashable-type-list-errors-whil 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…