AutoViML / AutoViz

Automatically Visualize any dataset, any size with a single line of code. Created by Ram Seshadri. Collaborators Welcome. Permission Granted upon Request.
Apache License 2.0
1.7k stars 196 forks source link

IndexError: list index out of range if type(df[depVar])==int32 #69

Closed ZhaiCong closed 2 years ago

ZhaiCong commented 2 years ago

if the type of target columns is int32,it seems meet some mistake ,because the function classify_print_vars does not treat type(int32). if I define target columns astype int64, the problem will solve. please add the infer function to type int32. Thanks!

image

if type(depVar) == str:
    if depVar == '':
        cols_list = list(dft)
        problem_type = 'Clustering'
        classes = []
    else:
        try:
            problem_type = analyze_problem_type(dft, depVar,verbose)
        except:
            print('Could not find given target var in data set. Please check input')
            ### return the data frame as is ############
            return dfte
        cols_list = list_difference(list(dft),depVar)
        if dft[depVar].dtype == object:
            classes = dft[depVar].factorize()[1].tolist()
            #### You dont have to convert it since most charts can take string vars as target ####
            #dft[depVar] = dft[depVar].factorize()[0]
        elif dft[depVar].dtype == np.int64:          ###################here#################             
            classes = dft[depVar].factorize()[1].tolist()
        elif dft[depVar].dtype == bool:
            dft[depVar] = dft[depVar].astype(int)
            classes =  dft[depVar].unique().astype(int).tolist()
        elif dft[depVar].dtype == float and problem_type.endswith('Classification'):
            classes = dft[depVar].factorize()[1].tolist()
        else:
            classes = []
AutoViML commented 2 years ago

Hi @ZhaiCong 👍 Nice Catch! I fixed the bug and you can test it by upgrading via:

pip install autoviz --upgrade

Thanks for trying out AutoViz. AutoViML