I have two dataframes where i want to append two columns based on a condition.
I have the two following dataframes:
I want to add TS%_mean and TS%_SD to the other data if the year matches to the first DataFrame so that each player has their mean and standard deviation for that year.
I have tried to itterate through a loop and having some conditions for the addition of columns. Everything I have tried does not work as intended unfourtunately.
1条答案
按热度按时间pnwntuvh1#
假设您有
df
和df2
,则可以使用merge
。您可能还需要学习joins。虽然链接是基于SQL的,但您将学习连接表的基础知识,以便创建更复杂的连接。