Pandas data frame update should be one of the most useful functions.
DataFrame.update(other, join='left', overwrite=True, filter_func=None, raise_conflict=False)[source]¶
Modify DataFrame in place using non-NA values from passed DataFrame. Aligns on indices
https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.update.html
Pandas dataframe merge with update data
Pandas dataframe merge with update data
print (pd.concat([df1, df2]).drop_duplicates('date', keep='last')) date value0 2017-01-01 11 2017-01-02 12 2017-01-03 10 2017-01-04 21 2017-01-05 22 2017-01-06 23 2017-01-07 24 2017-01-08 2
Concat works, but drop_dublicates('ID', keep='last') does not.
No comments:
New comments are not allowed.