fixed the issue. Will look into that further You can use itertools to get all subsets and create recursion function like this: from itertools import combinations
def test_method1(x):
print("METHOD 1 :", x)
def test_method2(x, y):
print("METHOD 2 :", x, y)
functions = [test_method1, test_method2]
variables = [1, 2, 3, 4, 5]
def run_all_methods(input_num):
if input_num > len(variables):
return
for item in functions:
try:
for var_list in set(combinations(variables * input_num,input_num)):
item(*list(var_list))
input_num += 1
except TypeError as a:
run_all_methods(input_num+1)
run_all_methods(1)
OUT:
===
METHOD 1 : 2
METHOD 1 : 5
METHOD 1 : 3
METHOD 1 : 1
METHOD 1 : 4
METHOD 2 : 1 3
METHOD 2 : 2 1
METHOD 2 : 5 1
METHOD 2 : 2 5
METHOD 2 : 1 2
METHOD 2 : 3 3
METHOD 2 : 5 5
METHOD 2 : 4 4
METHOD 2 : 1 5
METHOD 2 : 2 2
METHOD 2 : 3 4
METHOD 2 : 4 1
METHOD 2 : 1 1
METHOD 2 : 3 2
METHOD 2 : 5 4
METHOD 2 : 4 5
METHOD 2 : 1 4
METHOD 2 : 2 3
METHOD 2 : 4 2
METHOD 2 : 3 5
METHOD 2 : 5 3
METHOD 2 : 3 1
METHOD 2 : 4 3
METHOD 2 : 5 2
METHOD 2 : 2 4
a ==> [1, 2]
combinations(a, 2) => (1, 2)
a * 2 ==> [1, 2, 1, 2]
combinations(b, 2) => (1, 2)
(1, 1)
(1, 2)
(2, 1)
(2, 2)
(1, 2)
set(combinations(b, 2)) => (1, 2)
(1, 1)
(2, 1)
(2, 2)
Boards Message : 
You Must Login
Or Sign Up
to Add Your Comments . 
Share :

Get all parameters combinations possible
Date : March 29 2020, 07:55 AM
I wish this helpful for you I have a list of parameters with possible values : , This is pretty easy with recursion: void ImplCombinations(List<prmMatrix> plist, string built, int depth, List<string> results)
{
if (depth >= plist.Count()) {
results.Add(built);
return;
}
prmMatrix next = plist[depth];
built += "[" + next.Name + ":";
foreach (var option in next.PossibleValues)
ImplCombinations(plist, built + option + "]", depth + 1, results);
}
List<string> GetCombinations(List<prmMatrix> plist)
{
List<string> results = new List<string>();
ImplCombinations(plist, "", 0, results);
return results;
}

find combinations of numbers stored in an array and store those combinations in another array
Tag : cpp , By : Mighty Mac
Date : March 29 2020, 07:55 AM
like below fixes the issue Lacking a specific reason to choose something else, you probably want to store the results in a vector. You can precompute the number of results quite easily  N items taken K at a time will produce N!/K!(NK)! total combinations.

All possible combinations of many parameters MATLAB
Date : March 29 2020, 07:55 AM
like below fixes the issue What you need is all combinations of your input parameters. Unfortunately, as you add more parameters the storage requirements will grow quickly (and you'll have to use a large indexing matrix). Instead, here is an idea which uses linear indicies of a (never created) n1*n2*...*nm matrix, where ni is the number of elements in each field, for m fields. % Add parameters here
params.corrAs = {'objective', 'constraint'};
params.size = {'small', 'medium', 'large'};
params.density = {'uniform', 'nonuniform'};
% Setup
f = fieldnames( params );
nf = numel(f);
sz = NaN( nf, 1 );
% Loop over all parameters to get sizes
for jj = 1:nf
sz(jj) = numel( params.(f{jj}) );
end
% Loop for every combination of parameters
idx = cell(1,nf);
for ii = 1:prod(sz)
% Use ind2sub to switch from a linear index to the combination set
[idx{:}] = ind2sub( sz, ii );
% Create currentParam from the combination indices
currentParam = struct();
for jj = 1:nf
currentParam.(f{jj}) = params.(f{jj}){idx{jj}};
end
% Do something with currentParam here
% ...
end

How can i find unique combinations of 2 columns, delete not unique combinations, keeping only first rows in pandas
Date : March 29 2020, 07:55 AM
Does that help I have a dataset that contains 2 columns. And there are data combinations. I want to find if there are not unique combinations and delete them keeping only the first row. , I believe you need sorting each row and remove duplicates: df = (pd.DataFrame(np.sort(df[['dim', 'linked_dim']], axis=1),
columns=['dim', 'linked_dim'])
.drop_duplicates())
print (df)
dim linked_dim
0 Customer group$Large DEPARTMENT$Sales
1 Customer group$Medium DEPARTMENT$Sales
2 Customer group$Small DEPARTMENT$Sales

Using 5player combinations to find subset of a dataframe contain specific 5player combinations, each column identifyin
Date : March 29 2020, 07:55 AM
Does that help If i understand you correctly, you should just be able to create a new index for each df based on the offplayer columns then set_index and use boolean indexing with .isin. I modified your sample df slightly to show you. # modified your sample data a little
df = pd.DataFrame(np.array([[1,2,3,4,5,11,12,13,14,15,5,5],
[1,2,3,4,6,11,12,13,14,15,4,4],
[1,2,3,4,5,11,12,13,14,16,3,5],
[2,3,4,5,6,11,12,13,14,15,5,5],
[1,2,3,4,5,11,12,13,14,17,5,5],
[1,2,3,4,7,11,12,13,14,17,5,5]]),
columns=['offplayer1','offplayer2','offplayer3','offplayer4','offplayer5',
'defplayer1','defplayer2','defplayer3','defplayer4','defplayer5',
'possessions','points'])
# def players your are looking for
defplayers = [11,12,13,14,15]
# create df2 through boolean indexing
df2 = df[df[df.columns[5:10]].isin(defplayers).all(1)]
# create new indices
df_idx = df.columns[:5].values.tolist()
df2_idx = df2.columns[:5].values.tolist()
# boolean indexing to filter df
df[df.set_index(df_idx).index.isin(df2.set_index(df2_idx).index)]

