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 value
0 2017-01-01 1
1 2017-01-02 1
2 2017-01-03 1
0 2017-01-04 2
1 2017-01-05 2
2 2017-01-06 2
3 2017-01-07 2
4 2017-01-08 2
Concat works, but drop_dublicates('ID', keep='last') does not.
No comments:
New comments are not allowed.