0

I have a question regarding joining two datasets together. I now have data that looks like this: (example)

| dummy    | ID    | current year|
| -------- | -------------- |-------   |
| 0        | 1           |1621
| 0        | 1           |1622
| 0        | 1           |1623
| 1        | 1           |1624
| 0        | 2           |1623
| 0        | 2           |1624
| 0        | 2           |1625
| 0        | 2           |1626
| 0        | 2           |1627
| 1        | 2           |1628

I have another huge dataset containing all sorts of information about every transaction, for example:

| Gender    | ID    | Price| 
| -------- | -------------- |-------   |
| 1        | 1           |16
| 0        | 2           |12
| 0        | 3           |13
| 1        | 4           |22
| 0        | 5           |23
| 0        | 6           |38
| 1        | 7           |10
| 0        | 8           |16
| 0        | 9           |17
| 1        | 10           |8.

I now want to add a column to the first dataframe, which states the gender for every row. I guess this could be done by looking at the ID. Note that the first dataset has multiple rows per ID, and is thus much longer. I have no idea how to do this so any help would be appreciated, let me know if anything is still unclear :) Like this:

dummy ID current year Gender
0 1 1621 1
0 1 1622 1
0 1 1623 1
1 1 1624 1
0 2 1623 0
0 2 1624 0
0 2 1625 0
0 2 1626 0
0 2 1627 0
1 2 1628 0
Ronak Shah
  • 377,200
  • 20
  • 156
  • 213

0 Answers0