vendredi 10 septembre 2021

Why is the "else" line giving an invalid syntax error even with proper indentation and syntax? [closed]

I know this question has been asked many many times on here, but I seem to not have the same issues as others. I continually get "syntax error invalid syntax else", but do not know why this is. I seem to have everything properly indented and colons after the else statement. Any help would be much appreciated. Thanks

def normalization (fname, attr, normType):
    result = {}
     
    df = pd.read_csv(fname)
    targ = list(df[df.columns[attr]])
    scaler = MinMaxScaler()
     
    df["minmax"] = scaler.fit.transform(df[[df.columns[attr]]])
    
    df["zscore"] = ((df[[df.columns[attr]]]) - (df[[df.columns[attr.mean()]]]))/(df[[df.columns[attr.std(ddof=1)]]])
    

    if normType == "min_max":
        result = dict(zip(targ, df.minmax.values.tolist())
    
                  
    else:
        result = dict(zip(targ, df.zscore.values.tolist())
        
                                                
    return result

Aucun commentaire:

Enregistrer un commentaire