I have a dataframe called df1 and a list of dataframes called list.
In each of them exists columns date, like 2019-01-01 and another columns ID (not unique), and some other stuff.
Example:
df1
ID date Name
111 2019-01-01 John
222 2019-01-01 Smith
333 2019-01-01 Sam
list = [df_A, df_B, df_C]
# Example from a list:
df_A
ID date Name
111 2019-01-02 Katrin
222 2019-01-02 Ivan
333 2019-01-02 Leo
df_B
ID date Name
111 2019-01-01 John
222 2019-01-01 Smith
333 2019-01-01 Sam
df_C
ID date Name
111 2019-01-09 Sam_1
222 2019-01-09 Leo_1
333 2019-01-09 Marcel
I want to append values to df1 based on ID and Date from this list of dataframes.
Conditions are:
- If the max date for ID 111 in df1 are equal than the max date for ID 111 in one of the df from list, then do nothing.
- If the max date for ID 222 in df1 are less than the max date for ID 222 in one of the df from list, then do some stuff.
How the putput should look like:
df1
ID date Name
111 2019-01-01 John
222 2019-01-01 Smith
333 2019-01-01 Sam
111 2019-01-02 Katrin
222 2019-01-02 Ivan
333 2019-01-02 Leo
111 2019-01-09 Sam_1
222 2019-01-09 Leo_1
333 2019-01-09 Marcel
The date from df_B is equal to df1, so we don't update df1, but for other 2 dfs we need to append their values to df1
df_C, please follow the guidelines so it's easier to help