我创建了一个类,并且在这个类中有两个功能。因此,第一个函数使用第二个函数的结果,但是当我运行代码时,会出现以下错误:NameError:未定义名称'index'
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;
我在做什么错了?