Reputation: 99
I would like to update a larger DataFrame, using a smaller one. They have the same columns, but the larger DataFrame contains many more rows than the smaller DataFrame. It is for updating hockey stats, updating the DataFrame containing all NHL players with a DataFrame containing stats from a single game, both indexed by players' names, as below:
In [95]: total_stats
Out[95]:
G A
Chris Chelios 1 1
Zdeno Chara 2 2
Viktor Kozlov 3 3
Adam Oates 4 4
Wes Waltz 5 5
In [97]: game_stats
Out[97]:
G A
Chris Chelios 1 1
Zdeno Chara 0 0
I want to update the total_stats df (but not using df.update() or df.add() as it fills any non-overlapping rows with NaN) with the stats in the game_stats df, so that it looks like:
In [95]: total_stats
Out[95]:
G A
Chris Chelios 2 2
Zdeno Chara 2 2
Viktor Kozlov 3 3
Adam Oates 4 4
Wes Waltz 5 5
I've looked extensively online and while this seems like a fairly simple procedure, I'm having a rough time finding an answer
Thank you!
Upvotes: 1
Views: 38