Rodrigo Eduardo
Rodrigo Eduardo

Reputation: 23

How to join every value in one dataframe to every row in another?

I would like to insert the same information beside every row using pandas. For example, I have a dataframe with columns: Name, Age. and another datafreme with only one column: COLOR, and i would like to combine both as below:

enter image description here

Upvotes: 2

Views: 1256

Answers (1)

iacob
iacob

Reputation: 24251

You want the Cartesian product of the data frames. Use

df1.merge(df2, how='cross')

Upvotes: 3

Related Questions