0

I create a class and I have two functions in this class. So, the first function uses the result of the second, but when I run the code the following error appears: NameError: name 'index' is not defined

class ClusterGenero:
    def __init__(self,df_main_user,df_trabalho):
        self.df_main_user = df_main_user
        self.df_from_workspace = df_trabalho

    def clusterizar(self):

        df_aux_main_user = df_aux_main_user.loc[:,['movieId','cluster']]

        df_frequencies= df_aux_main_user['cluster'].value_counts()
        aux = df_frequencies.max()

        main_user_cluster = index(aux)

        df_workspace = df_trabalho[df_trabalho['cluster'].isin([main_user_cluster])]
        df_workspace = df_trabalho.reset_index(drop=True)

        df_aux = df_original.loc[:,['userId','movieId','rating']]

        return df_to_aux

    def index(self,aux):
        for i in range(len(df_frequencies)):
            if df_frequencies[i] == aux:
                return i
                break;

What am I doing wrong?

Mariana
  • 165
  • 1
  • 1
  • 8

0 Answers0