Have you ever tried to make a copy of a DataFrame using =
? You will not get a copy but a reference to the original DataFrame. Thus, changing the new DataFrame will also change the original DataFrame.
A better way to make a copy is to use df.copy()
. Now, changing the copy will not affect the original DataFrame.