i want to merge rows together based on the ID because i have duplicate rows, but there are some columns with missing data please see my examples below for clarity.
below is what my current df looks like:
id|name|snack|treat|age|year|
---|---|---|---|---|---|
ab1|maria|pretzel| |20| |
cd2|jordan| | | |1998
ef3|canela| |cookie|||
ab1|maria||brownie|20|2012
ef3|canela|chips| ||
cd2|jordan||||1998
cd2|jordan|goldfish||25|
this is what i want the combined data to look like:
id|name|snack|treat|age|year|
---|---|---|---|---|---|
ab1|maria|pretzel| brownie|20|2012 |
cd2|jordan|goldfish||25|1998
ef3|canela|chips|cookie|||
how can i get these to merge based on their id?
thanks in advance!!