Pandas DataFrame: update() function

DataFrame - update() function

The update() function is used to modify in place using non-NA values from another DataFrame.

Aligns on indices. There is no return value.


DataFrame.update(self, other, join='left', overwrite=True, filter_func=None, errors='ignore')


Name Description Type/Default Value Required / Optional
other             Should have at least one matching index/column label with the original DataFrame. If a Series is passed, its name attribute must be set, and that will be used as the column name to align with the original DataFrame.  DataFrame, or object coercible into a DataFrame Required

Only left join is implemented, keeping the index and columns of the original object.

Default Value: 'left'
overwrite    How to handle non-NA values for overlapping keys:
  • True: overwrite original DataFrame's values with values from other.
  • False: only update values that are NA in the original DataFrame.
Default Value: True
filter_func   Can choose to replace values other than NA. Return True for values that should be updated. callable(1d-array) -> bool 1d-array Optional
errors   If 'raise', will raise a ValueError if the DataFrame and other both contain non-NA data in the same place.
Changed in version 0.24.0: Changed from raise_conflict=False|True to errors='ignore'|'raise'..
{'raise', 'ignore'}
Default Value: 'ignore'

Returns: None - method directly changes calling object

Raises: ValueError
  • When errors='raise' and there's overlapping non-NA data.
  • When errors is not either 'ignore' or 'raise'


Download the Pandas DataFrame Notebooks from here.

Previous: DataFrame - merge() function
Next: DataFrame - asfreq() function

Follow us on Facebook and Twitter for latest update.