890 questions
2
votes
4
answers
182
views
How to get the cartesian product (cross join) of two sets via Excel Formulas
I need to get the cartesian product of two "sets" via Excel 365 Formulas (not VBA, not Power Query). For instance, my two sets are the two left tables, and the expected cartesian product is ...
3
votes
2
answers
289
views
Am I misunderstanding how `std::views::cartesian_product` is supposed to work?
Edit: see also a connected question.
I have tested the following program on godbolt:
#include <algorithm>
#include <iostream>
#include <ranges>
#include <sstream>
int main() {...
0
votes
1
answer
46
views
How to create the cartesian product of a list of lists of tuples
I'm trying to accomplish a cartesian product of a list of lists. The base elements are tuples. Something about the tuples seems to really throw product off. The more products I attempt the more it ...
-2
votes
2
answers
238
views
Remove duplicate rows from LEFT JOIN with SELF JOIN
How to create a join that has all product_features with all feature_text rows
that joins a specific text for a feature if available
or else joins the general text for that feature?
The join must not ...
0
votes
0
answers
18
views
Node JS Cartesian functions are too memory consuming
I've made two different functions to calculate all possible combination of elements from n arrays (n not fixed, this is very important to notice) where each array contains a different number of ...
2
votes
1
answer
41
views
Cartesian product of dict of lists in Python [duplicate]
I would like to have a Python function cartesian_product which takes a dictionary of lists as input and returns as output a list containing as elements all possible dictionary which can be formed by ...
1
vote
0
answers
89
views
Select Data from Two Tables without a Join (Cartesian Product) in Gorm
I'm trying to select data from two SQL tables without a join. Essentially, I need a Cartesian Product of the two tables. The SQL statement I expect to use is: SELECT * FROM table1, table2 WHERE table1....
1
vote
1
answer
71
views
Batch processing on itertools python
I'm trying to normalize a JSON file using python.
Basically, I iterate through this JSON appending its values to different lists. Then, I union all this lists using itertools.product.
When I have a ...
2
votes
2
answers
77
views
Dynamic Matrix Columns combinations
I would like to find all possible combinations of a matrix columns, with each column contributing a value, in each iteration of a loop. The matrix size changes in each iteration. For example:
A = [1 ...
0
votes
3
answers
93
views
How can I create a product of a 2-dimensional list with a 1-dimensional list (needs to be one-liner)? [duplicate]
I have two lists that I'm trying to combine:
lst1 = [['arg1', 'arg2']] # this can have more lists, but for simplicity, leaving it as this
lst2 = ['arg3', 'arg4']
I want the product of the two lists ...
1
vote
3
answers
77
views
How to make a certain double cartesian product with jq?
Suppose I have this dataset:
{"id": 99, "labeled_values": [["one", "green"], ["two", "red"], ["three", "blue"]], "...
0
votes
0
answers
26
views
How to perform multiparameter sweeps interfacing with a hardware aparatus?
I've written a lot of redundant code to control an experimental apparatus with python.
The Cartesian product almost solves everything, but there's still one hickup I need help with.
Here's the story:
...
-2
votes
3
answers
92
views
Cartesian product without reuse
I have two generators producing data, for example:
def xs():
yield [1, 2]
yield [3, 4]
def ys():
yield [5, 6]
yield [7, 8]
And I want to process all possible (x,y) pairs:
process([1, ...
0
votes
0
answers
45
views
All Possible Combinations (cartesian product) Script/Functions with no duplicate values
At a school, we are trying to determine if based on when we are able to offer all of our classes (master schedule) if based on each student's course requests can a schedule be built where they receive ...
0
votes
1
answer
57
views
SQL Cursor multiply two sets of lines
I am using Hana data studio (SQL) and need to write a cursor that takes the original dataset, makes column age set to 0 and sets the the fiscal quarter to the iterated value over a distinct list of ...
-1
votes
3
answers
197
views
Repeat Value for Every Instance of Another Value in Excel without using Power Query
I have about a thousand products in a table. In another table, I have 33 price contracts. I need an instance of each product for every contract.
For example, if I had the 4 following products:
...
0
votes
2
answers
123
views
Pyspark Cartesian product of two columns in a dataframe
I have a pyspark DataFrame that contains to columns, each one is an array of strings, how can I make a new column that is the cartesian product of them without splitting them to two dataframe and join ...
0
votes
1
answer
40
views
Enumerating and correlating tables to avoid cartesian joins
I have a set of tables that I want to pull all the data from, with columns listing the contents of the ancillary tables.
For example:
states
code
name
AR
Arkansas
CT
Connecticut
MN
Maine
senators
...
0
votes
2
answers
62
views
cartesian combinations for component variants
Let's say I have an object specifying inputs for a button component, and the possible values of that input.
const buttonVariants = {
colorMode: ['on-dark','on-light'],
size: ['small','medium','...
-1
votes
2
answers
85
views
Facing trouble in creating sublists of a list
My task is to create combinations, more like a Cartesian product for some attribute lines of a library file. I am currently facing the problem of grouping the same attributes(of course the adjacent ...
1
vote
1
answer
55
views
Typescript Generic for cartesian product
Here is a typescript Cartesian product iterator:
export function* productIterator3<T1, T2, T3>(
...arr: [T1[], T2[], T3[]]
): Generator<[T1, T2, T3]> {
const lengths = arr.map((...
2
votes
1
answer
157
views
Better way to combine in Kotlin?
I want to combine all elements from one list with all elements from another list, to obtain all possible pairs.
Of course, we can do this in a loop (not tested):
val list1 = listOf(1, 2, 3)
val list2 =...
1
vote
1
answer
85
views
Creating a function showing all combinations [duplicate]
I'm having trouble here turning a vector of vectors with different lengths into a matrix with all possible combinations. For example, I am wanting the below
vector <vector <double>> ...
0
votes
1
answer
21
views
How to search for elements in the $n$-th power of a set without actually creating the $n$-th power set?
There is a given set S. I would like to search for elements from $S^n$ (the
Cartesian product of $S$ with itself $n$ times) that verify certain properties. But I don't want
to actually create $S^n$ ...
0
votes
3
answers
382
views
Multiply all possible combinations for rows - Cross Join set row with multiple columns
Hi I have a similar problem in Google sheets that is solved in this thread:
Generate all possible combinations for Columns(cross join or Cartesian product)
i am trying to join multiple rows with ...
0
votes
3
answers
253
views
How to do a cartesian join of a numpy array and a pandas series?
I have a numpy array ids (unique) and a pandas series dates.
I want to create a pandas dataframe that is a cartesian product of ids and dates with columns id and date grouped by date.
e.g., ids = [1, ...
3
votes
3
answers
148
views
Product between MultiIndex and a list
I have a MultiIndex object with 2 levels:
import pandas as pd
mux = pd.MultiIndex.from_tuples([(1,1), (2,3)])
>>>
MultiIndex([(1, 1),
(2, 3)],
)
I want to multiply it ...
0
votes
2
answers
181
views
Is there a way to implement a cartesian product over iterators that are *not cloneable*?
The idea is that I want the cartesian product of iterators that are all Box<dyn...>, because I have a function higher up that returns different types of iterators, some of which must be run ...
0
votes
1
answer
94
views
Embed SUMIF / Vlookup / Index-Match functions in Recursive Lambda functions in Google Sheets
Question:
Following on from this question:
Recursive Lambda Functions for Cartesian Products in Google Sheets
How would I add columns in a generative array which looks up values from the resulting ...
1
vote
2
answers
49
views
Iterating over the cartesian product of a list of lists
The problem is a generalization of the folling simple problem:
Given 3 lists of elements, I can loop over the pairings between all 3 lists by folling pseudocode:
foreach( element1 in list1 )
...
0
votes
1
answer
131
views
Get cross product of two enums in Rust without Typing them all out
Say for example we have two enums that represent the Rank and Suit of a deck of standard playing cards:
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)]
enum Suit {
Spades,
Hearts,
...
0
votes
1
answer
45
views
getting random sampling from cartesian product
Consider the complex number z = x+iy. I have an object constructor class that can take a complex number and plot something from it, say pole(x,y).
I want to construct an array that considers all the ...
1
vote
1
answer
51
views
Product of the Dictionary Values from Combinations of Dictionary Keys in Python
I have a dictionary of sets in Python
dct={'k1':{1,2,3,4},'k2':{100,200},'k3':{1000,2000,3000,4000},'k4':{25,50}}
and I want to find the Cartesian product of all the possible combinations of, say 3 ...
0
votes
1
answer
121
views
Excel: DataModel - why it returns cartesian product?
Can't understand how DataModel works in Excel.
Please help
Example:
in Excel - why it returns cartesian product?
At the same time absolutely the same DataModel in PowerBi returns normal estimated ...
0
votes
0
answers
412
views
DAX Match Row then Multiply each Column by matched value keeping Column structure
I am not sure if I am missing something obvious, as I am new to the DAX language.
I have 2 tables, one contains equipment with total quantities, the other has the corresponding set of components for ...
0
votes
1
answer
142
views
cross merge/cartesian product in dask
how can I perform the equivalent of this cross merge in dask?
merged_df = pd.merge(df, df, how='cross', suffixes=('', '_y'))
To provide an example, say I have this dataframe, say dataframe A:
#Niusup ...
0
votes
1
answer
16
views
How can I find the maximum integer representable by a given count of cubes with single digit integers painted on the six sides
Backstory - I have a baby on the way and have come across a product that is wooden cubes with single digits painted on the side.
They come in a set of three cubes and a units block, with the idea ...
-2
votes
2
answers
185
views
Cartesian array of objects in Javascript
I have been working on a Cartesian product with a below array of objects.
[
{
"name": "Size",
"values": ["10", "39"]
},
{
...
1
vote
0
answers
54
views
How to avoid Cartesian product when merging in Python using Pandas
I want to merge three CSV tables (average speed, traffic flow, car count) in Python to try and build a traffic prediction project using RNNs. However, when I try to merge car count I get a Cartesian ...
4
votes
1
answer
985
views
Cartesian product of n ranges
I am rewriting a python program into rust and I am struggling to translate this line:
itertools.product(range(0,8), repeat=n)
What I am trying to achieve is something like this: https://pastebin.com/...
0
votes
1
answer
126
views
How to avoid cross product/Cartesian/full join in SQL?
We have a table A with column "ETA To Destination" in minutes.
id
ETA To Dest (mins)
Score
1
45
2
75
There is a configuration table where we have defined scores based on the time ...
1
vote
5
answers
170
views
Generate all combinations of positive and negative
I have this list of tuples
a = [(1, 2), (2, 1)]
And need all of the possible combinations of negative and positive:
b = [(1, 2), (1, -2), (-1, 2), (-1, -2), (2, 1), (2, -1), (-2, 1), (-2, -1)]
I've ...
0
votes
0
answers
24
views
Generating combination of list items in python [duplicate]
I have 3 python lists:
x = ["a", "b", "c"]
y = ["d", "e", "f"]
z = ["m", "n", "s"]
I want to generate all ...
1
vote
1
answer
228
views
Efficient Cartesian product within groupby
I would like to do the Cartesian product (e.g. pandas merge with how='cross') between each row and all other rows, but in a groupby. I have found several ways to do it, but they take more than a day ...
1
vote
3
answers
309
views
How would I get a list of pairs where every element from list1 is paired with some element from list2?
So I have this problem in my head that I'm trying to solve iteratively instead of recursively, but the solution seems to elude me despite it seemingly being so easy.
Let's say I have two lists
l1 = [a,...
0
votes
1
answer
108
views
Modify an existing named function that returns a Cartesian product / cross join by adding an argument that specifies the # of columns/values per row
I found the following Google Sheets named function CARTESIAN_PRODUCT as an answer to a related question Here:
=IF(COLUMNS(range) = 1, IFNA(FILTER(range, range <> "")), LAMBDA(...
2
votes
0
answers
893
views
Is there a faster Python algorithm to iterate through grouped Cartesian product pairs?
I have two files (lhs and rhs), each with a grouping-variable field (other variables exist too).
The goal is to iterate through the Cartesian product pairs within each grouping-variable value as ...
2
votes
3
answers
758
views
Flatten nested JSON to array of unique objects without indexes
I have this simple nested object which I need to flatten to be able to insert it into my database.
const input = {
name: "Benny",
department: {
section: "Technical",
...
1
vote
1
answer
56
views
Some combinations of nested dictionaries with arbitrary lengths in python
I have a game tree with an arbitrary number of possible moves for me and my opponent with an arbitrary sequence of moves. I want to get an overview of all 'sets of moves I can make' and corresponding ...
1
vote
2
answers
134
views
Shuffle a cartesian product iterator in Javascript
Using a library like https://www.npmjs.com/package/cartesian-product-generator I am able to generate a cartesian product iterator. This is necessary when I have, say 4 arrays, each of length 100, ...