So I'm asking a question about the group in a completely ignorant way.
I would like to be able to fill a pandas DataFrame "df1" (600 rows and 7 columns) from a pandas DataFrame "df2" summary of (20 rows 7 columns), where df1 contains all the rows of df2 but in much larger size.
My question is if there is a method to fill in df1 from df2. The columns are identical as shown in the following picture:
In short, it is a question of constructing the df1 from the summary df2.
Is this operation possible and feasible?
Do you have any ideas or the beginnings of a solution?
Thank you in advance for your thoughts.
Good day to everyone:)
df2.index = df2["Tag"]
df1.index = df1["Tag"]
del df1["Tag"]
del df2["Tag"]
df2 = df2.apply(lambda x: df1.loc[x.index].values.tolist())[0]
pd.DataFrame(df2.tolist(),df2.index)
a fast implementation way then, you can set tag column:
df2["Tag"] = df2.index
df1["Tag"] = df1.index
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.