'I have a list of three dataframes i want to update df1 values into df2 and df2 values into df3 now my final df3 need to contain all updated values
My code is :
dfs = [df1,df2,df3]
le = dfs[0].drop_duplicates(subset=['id'])
df = dfs[1].set_index('id')
df.update(le.set_index('id'))
df.reset_index(inplace=True)
le1 = df.drop_duplicates(subset=['id'])
df1 = dfs[2].set_index('id')
df1.update(le1.set_index('id'))
df1.reset_index(inplace=True)
My final output is:
myfinalupdateddf = df1
How can I do my above code into dynamic way by using for loop instead of creating multiple variables to get my final output.?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
