I've created a for loop in python that iterates through each column in my dataset. I then have some logic that I want to apply to some rows in a dataframe, and it varies depending on which column I am using. Here is the code I'm using:
nameList2 = ["name1", "name2", "name3"]
nameList2 = ["nameX", "nameY", "nameZ"]
for col in df.columns:
if col in nameList1:
df[(np.abs(stats.zscore(df)) < 3).all(axis=1)]
if col in nameList2:
df = df[(np.abs(stats.zscore(df)) < 6).all(axis=1)]
When I run my code, it doesn't actually affect my dataframe, however, I know my logic works as when I run it for all the column at once, I can see the changes. Can anyone indicate what is wrong with my if statement?
Aucun commentaire:
Enregistrer un commentaire