I read this documentation but I do not understand what the overwrite option actually does to the update process. I tested with a few cases but in each whether or not I set overwrite to True or False makes no difference. Can someone give an example where it does make a difference?
1 Answer
The difference is that when overwrite is set to false, it will only fill in missing values in the DataFrame that update was called on.
Based on the example from the link you supplied (using the default value overwrite=True):
df = pd.DataFrame({'A': [1, 2,3], 'B': [400, None, 600]})
new_df = pd.DataFrame({'B': [4, 5, 6], 'C': [7, 8, 9]})
df.update(new_df)
yields:
A B
0 1 4.0
1 2 5.0
2 3 6.0
whereas df.update(new_df, overwrite=False) yields:
A B
0 1 400.0
1 2 5.0
2 3 600.0