mercredi 21 août 2019

How to check multiple statements in Dataframes with if? Python

There are 1 dataframe = df1 and a list of dataframes = 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-01  Katrin
222  2019-01-05  Ivan
333  2019-01-02  Leo


I want to append values to the df1 on the base of 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.

I googled but didn't get if it's possible

Aucun commentaire:

Enregistrer un commentaire