All Questions
11 questions
3
votes
1
answer
3k
views
How to get all combination for a given sum with a given number of elements
I have a list of list of floats like this
numbers = [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9]
I want a python code that can generate all possible combinations for given sum (=1) and a given number of ...
0
votes
1
answer
26
views
Is there another different way of printing a cartesian product in a dictionary which has arrays as values following an specific order on Python?
Let's say I have the following dictionary:
the_dictionary_list = {'Color': ['Amarillo.png', 'Blanco.png', 'Rojirosado.png', 'Turquesa.png', 'Verde_oscuro.png', 'Zapote.png'],
'...
2
votes
1
answer
482
views
Retrieve all possible combinations of ascending integers from sublists
I have lists containing sublists. From theses lists I want to retrieve all combinations of integers that are in ascending order. Also the order of the sublists is important (see expected output).
It ...
0
votes
1
answer
1k
views
How to get n-length Boolean array with conditions on X amount of 'True' values
I have the following list of events that have a binary outcome (i.e. 1 or 0):
events=['A', 'B', 'C']
outcomes=[True,False]
in each scenario, only one of these outcomes can be True. Is there a way to ...
0
votes
2
answers
312
views
Python itertools.combinations: how to obtain the indices of the combined numbers within the combinations at the same time
According to the question presented here: Python itertools.combinations: how to obtain the indices of the combined numbers, given the following code:
import itertools
my_list = [7, 5, 5, 4]
pairs = ...
-3
votes
2
answers
119
views
Find the highest sum combination with conditions from a list
So I have a 360 element list that I want to find the highest sum of 11 numbers combination, but with a condition.To make it a bit clearer:
1-Gets a list as input
2-Create a combination list with 11 ...
0
votes
0
answers
31
views
Pythonic efficient way to compute the mean of two successives arrays and add the resulted array between them
l have 9000 array of arrays called my_data=(9000,). Each array is composed of a number of arrays.
len(my_data[0])=345 arrays# each array of 2000 values
len(my_data[700])=222 arrays s# each array of ...
0
votes
0
answers
499
views
How to apply a function to a Cartesian product efficiently in Python/Numpy?
I have a function that I would like to apply on each element of a cartesian product of a linear space. I do know how to do it with functions of one variable that is defined using lambda, namely using ...
3
votes
1
answer
2k
views
Python: Finding all possible unique two-index combinations in a 2D array
I have a numpy array that is roughly equivalent to:
data = ([1, 2, 3], [4, 5, 6], [7, 8, 9])
I want to find all the unique two-index combinations of these values. In other words, I want all the ...
2
votes
3
answers
482
views
possible unique combinations between between two arrays(of different size) in python?
arr1=['One','Two','Five'],arr2=['Three','Four']
like itertools.combinations(arr1,2) gives us ('OneTwo','TwoFive','OneFive')
I was wondering is there any way applying this to two different arrays.?I ...
2
votes
2
answers
1k
views
possible combinations of strings in an array in python?
arr=['one','two','three']
Result must be like this:
onetwo,twothree,onethree
itertools.permutations will not work in this situation.
we can do this by simply adding for loops and appending them ,...