Skip to main content

All Questions

-1 votes
3 answers
97 views

Iterate over different lists

I'm trying to itterate over 2 different lists in python and after this itteration I want to get new list, which will include new data. I have a code: import itertools current_week = [42,43,44,45,46] ...
Vitaliy's user avatar
  • 38
0 votes
0 answers
52 views

Iterate through for loop indices

I have the following lines of code which I am converting to a function to iterate up to 'n' times import numpy as np x_set1 = np.array(x_set[0], x_set[0]) x_set2 = np.array(x_set[1], x_set[1]) ...
zee bee's user avatar
0 votes
1 answer
130 views

problem with itertools permutations in combination with english_words_set in a for loop

I want to get all possible words with 5,6,7 characters from a random string: word="ualargd" I do the following: A for loop to change the length of my permutations. for i in range(5,len(...
tetris programming's user avatar
0 votes
2 answers
105 views

Python : Replace two for loops with the fastest way to sum the elements

I have list of 5 elements which could be 50000, now I want to sum all the combinations from the same list and create a dataframe from the results, so I am writing following code, x =list(range(1,5)) t=...
Kallol's user avatar
  • 2,189
0 votes
0 answers
33 views

Generate multiple nested for loops based on number of hyperparameters

I have augmentation methods to augment a given data set. These augmentation methods have different number of hyperparameters. Now I want to implement a generic Jupyter Notebook to iterate through the ...
Invader's user avatar
  • 171
0 votes
1 answer
106 views

Iterate over an array of lists without Itertools

I have an array of lists array_of_lists, of which I need every combination of elements. The number of elements of array_of_lists should not be predefined. The usual way would be to use itertools....
Mjom's user avatar
  • 1
2 votes
1 answer
56 views

Iteration via expandable nested 'for' loops without itertools

I am trying to make a list of iterations of the alphabet with itself to the n-th power but I am unable to find an appropriate way of achieving this. I would rather not use itertools for the time being....
NPM's user avatar
  • 91
0 votes
2 answers
49 views

n FOR loops in python with changable iterable, need help understanding

I am doing a project which calculates how many combinations there are of a old-fashioned android lock screen. So the lock screen is a 3x3 shown on image where the first row is respectively A, B, C, ...
Michal Pielka's user avatar
0 votes
1 answer
308 views

How can I use itertools to simplify this nested for loop?

How can I use itertools to simplify this nested for loop? # pytest file: def get_test_cases(): with open("file_path.yml", "r", encoding="utf-8") as index_file: ...
Daniel Arapi's user avatar
0 votes
3 answers
102 views

Listing Column Names with Itertools

I have this Dataframe: STATE CITY TAX_C MATERIAL IG LIMIT 0 TX DALLAS 1 CARP 0 5 1 TX DALLAS 1 BLAY 0 10 And I've created a loop using ...
Owen's user avatar
  • 308
1 vote
2 answers
206 views

How to get unique pair from nested loop in Python

I am trying to find correlations between dataframe columns using nested loop. import itertools for col1 in df.columns: for col2 in df.columns: if col1!=col2 and col1 not in (["Country&...
beridzeg45's user avatar
0 votes
4 answers
104 views

Iterator to reverse a for loop's order of execution?

I have been searching the docs for itertools, as well as SO for a while now and have not yet found what I'm looking for. I'm hoping to reverse the order of execution of a for loop so the following ...
pbthehuman's user avatar
2 votes
1 answer
138 views

Two nested for loops involving itertools don't produce the permutations of the outer loop

I have the following bit of code: a = [0,1,2,3,4] b = range(6) p = itertools.permutations(a) p2 = itertools.product(b,b,b,b,b) for pos in p: for shift in p2: print(pos,shift) which ...
sodiumnitrate's user avatar
2 votes
1 answer
94 views

Skipping an Iteration in a Specific List when Iterating through Multiple Lists

This question is somewhat similar to this question, but different in that it entails multiple lists: I have three lists: a = [1, 2, 3, 4, 5, 6, 7] b = ['ball', 'cat', 'dog', 'elephant', 'baboon', '...
john_mon's user avatar
  • 527
1 vote
1 answer
274 views

Extending and optimizing 2D grid search code to N-dimensions (using itertools)

I have code for a 2D grid search and it works perfectly. Here is the sample code: chinp = np.zeros((N,N)) O_M_De = [] for x,y in list(((x,y) for x in range(len(omega_M)) for y in range(len(omega_D))))...
shram's user avatar
  • 25

15 30 50 per page
1
2 3 4 5 6