Hey, I wanted to create cartesian products using two different DataFrames in pandas but I was facing difficulty in doing this. Here’s my dataset:
# Creating two datasets with integer values
df1 = pd.DataFrame({'A': [1, 2, 3]})
df2 = pd.DataFrame({'B': [4, 5]})
and this is what my expected output is:
A B
0 1 4
1 1 5
2 2 4
3 2 5
4 3 4
5 3 5
How can I do this? Is there any function in pandas or any other efficient way to create cartesian products?