@@ -3143,7 +3143,7 @@ def combine_first(self, other):
3143
3143
combiner = lambda x , y : np .where (isnull (x ), y , x )
3144
3144
return self .combine (other , combiner )
3145
3145
3146
- def update (self , other , join = 'left' ):
3146
+ def update (self , other , join = 'left' , overwrite = True ):
3147
3147
"""
3148
3148
Modify DataFrame in place using non-NA values from passed
3149
3149
DataFrame. Aligns on indices
@@ -3152,6 +3152,9 @@ def update(self, other, join='left'):
3152
3152
----------
3153
3153
other : DataFrame
3154
3154
join : {'left', 'right', 'outer', 'inner'}, default 'left'
3155
+ overwrite : boolean, default True
3156
+ If True then overwrite values for common keys in the calling
3157
+ frame
3155
3158
"""
3156
3159
if join != 'left' :
3157
3160
raise NotImplementedError
@@ -3160,7 +3163,11 @@ def update(self, other, join='left'):
3160
3163
for col in self .columns :
3161
3164
this = self [col ].values
3162
3165
that = other [col ].values
3163
- self [col ] = np .where (isnull (that ), this , that )
3166
+ if overwrite :
3167
+ mask = isnull (that )
3168
+ else :
3169
+ mask = notnull (this )
3170
+ self [col ] = np .where (mask , this , that )
3164
3171
3165
3172
#----------------------------------------------------------------------
3166
3173
# Misc methods
0 commit comments