Implement cross join (cartesian product)
- Dominant language
- C++
- Stars
- 1.9k
- Forks
- 164
- Avg merge
- 7h 31m
- Merged PRs (30d)
- 1
Description
- Describe what feature you would like to see implemented.
Implement cross join (cartesian product) - every row of the left Frame combined with every row of the right Frame.
For example, in pandas:
`cross_df = pd.merge(left_df, right_df, how='cross')`
conceptually, this works but is very slow:
`cross_dt = dt.rbind([dt.cbind(left_dt[i, :], right_dt[j, :]) for i in range(left_dt.nrows) for j in range(right_dt.nrows)])`
- If possible, give an example of how it may look in the code and what result
will be produced.
```
left_dt = dt.Frame({'left_col': [1, 2, 3]})
right_dt = dt.Frame({'right_col': [4, 5, 6]})
cross_dt = left_dt[:, :, join(right_dt, how='cross')] # something like this, I'm guessing
print(cross_dt)
| left_col right_col
| int32 int32
-- + -------- ---------
0 | 1 4
1 | 1 5
2 | 1 6
3 | 2 4
4 | 2 5
5 | 2 6
6 | 3 4
7 | 3 5
8 | 3 6
[9 rows x 2 columns]
```
- Click "Preview" to check that there are no formatting problems, that the
request is stated clearly, and that it is not overbroad in scope.
- Thanks for contributing. We appreciate your input!
Contributor guide
Assessment
This issue has not been assessed yet.