Pandas - Inplace, View, Copy Confusion
I'm having an issue with Pandas dataframes. It seems that Pandas/Python generate a copy of the DF somewhere in my code as opposed to performing the modifications to the original DF
Solution 1:
I think when you do:
df = df[df['file_exists'] != False]
You've created a copy of the original df.
To make it work, you can change your function to:
def clean_df2(df): #remove non-existing files from DF
df['file_exists'] = True # add column, set all to True?
.....
return df
And when you call clean_df2(df), do the following:
df = clean_df2(df)
Post a Comment for "Pandas - Inplace, View, Copy Confusion"