I've created a loop to get a list of rows to drop.
cols = []
for i in range(len(df)):
if i != len(df)-1:
if (df['Player'][i] == df['Player'][i+1]):
cols.append(i+1)
Now I want to go through cols and drop each row by its number. I've tried using the following loop to drop these rows but it's not working.
for col in cols:
df.drop([[col]])
df.drop()returns a dataframe, rather than modifying it in place; supplying aninplace = Trueargument should make your code work the way you want it to. But there is a better way to do this; see my answer below.