reset_index
by default does not modify the DataFrame; it returns a new DataFrame with the reset index. If you want to modify the original, use the inplace
argument: df.reset_index(drop=True, inplace=True)
. Alternatively, assign the result of reset_index
by doing df = df.reset_index(drop=True)
.