0

I looking for a simpler way to duplicate the number of rows in Dataframe 1 depending on the value in Dataframe 2 column "Game" (for each row)

I have 2 dataframe :

data1 = {'Source': ['Person', 'Person'],
          'Name': ['Alice', 'Bob'],
         'Age': [25, 30]}
df1 = pd.DataFrame(data1)


data2 = {'Source': ['object', 'object'],
         'Game': ['Ps', 'XBOX'],
         'Color': ['blue','red']}
df2 = pd.DataFrame(data2)

outpout :

DataFrame 1:
   Source   Name  Age
0  Person  Alice   25
1  Person    Bob   30

DataFrame 2:
   Source  Game Color
0  object    Ps  blue
1  object  XBOX   red

The final result should looks like this :

   Source1    Name     Age      Source2     Game    Color
0  Person     Alice    25       object      Ps      blue
2  Person     Alice    25       object      XBOX    red
3  Person     Bob      30       object      Ps      blue
4  Person     Bob      30       object      XBOX    red

Thanks for your help

hk77
  • 59
  • 8

0 Answers0