Questions tagged [iteration]
Iterations are the successive repetitions in loops such as for, foreach or while. Questions with this tag are often concerned about how to best handle a collection of data.
iteration
10,906
questions
0
votes
0
answers
15
views
How use each in cypress when element is detached from DOM after action [duplicate]
I have this cypress code and it works. I need to iterate through all the links on the page. After clicking on each link, a breadcrumb tab opens. After closing the tab, the page with the links returns.
...
-1
votes
1
answer
51
views
Javascript : Find node value through recursive iteration
I have the following structure :
var content = {
"id": "RkktMTA1OC0wNTE3QElNQi82NTAwNC9YLzAwSDc",
"name": "FI-1058-0517",
"category": &...
0
votes
1
answer
24
views
Iterate through all the days in a month in DJANGO template
enter image description here
I have a model table like above which contains two columns on which dates on which an item is being sold in a month.
I want to show the entire month table in Django ...
0
votes
0
answers
9
views
How to extract particular field from custom duplicate objects and build a another response list using java 8 streams
I have below response from database and I need to convert it into the final json format using java 8 streams.
Response from Database:
[
{
"name": "Test1",
"age": "33&...
-4
votes
1
answer
62
views
Python Apply function to create new rows in loop
Goal: Here is a sample of a dataset that has "ID", "PHASENAME", "CDAYS", "MULTI_FACTOR", "DAY_COUNTER", and "DAILY_LABOR_PERCENT". The goal ...
0
votes
1
answer
39
views
Not able to get iteration in curly codes or php correctly
I have uploaded images as follows:
image 1 (an image is uploaded)
image 2 (no image is uploaded)
image 3 (an image is uploaded)
image 4 (no image is uploaded)
image 5 ...
-2
votes
0
answers
22
views
Object Not Updating Inside FOR Loop [duplicate]
Can someone please explain why this object is not being updated? This has been annoying me for more than an hour. When I run the code on this website: https://playcode.io/1919282, the fillcolor is the ...
0
votes
1
answer
44
views
Azure DevOps Rest API - Creating Iteration don't work
First I call all iterations that I have in my project - and it works fine and then I want to create a new one via the API. , but the method doesn't work, I get the error:
The remote server returned ...
0
votes
1
answer
82
views
My C code is able to iterate once through and come up with the correct mileage but on the second iteration it fails
The problems objective is to write a program that takes a number of data sets the user would like to enter and then within the data sets it counts how many miles you traveled. For example for the ...
0
votes
5
answers
128
views
Variable number of nested array iterations in C
First, sorry if the title is not clear, but I don't know how to ask this properly.
Imagine I have an array of N elements, in this case 4:
#define ELEMENT_COUNT 4
int arr[ELEMENT_COUNT] = { 'a', 'b', '...
0
votes
0
answers
26
views
Execution is very slow for GAN
I wrote a code on GAN and had previously trained in the Colab environment. I leave the Colab code below.
def build_generator(latent_dim):
"""Build the generator model.""&...
2
votes
3
answers
106
views
How to iterate over multiple ranges / sequences / numbers specified in var?
I can iterate over multiple ranges / sequences / numbers with constructions like:
for i in $(seq 1 3) 5 $(seq 7 9) 11; do echo $i; done
for i in {1..3} 5 {7..9} 11; do echo $i; done
But how to ...
1
vote
3
answers
73
views
How to iterate through a dictionary to get values on the lowest level?
Please help me understand how to extract the value of each ingredient for each product and do something with it. But for starters I just want to print them all one by one.
MENU = {
"product_1&...
0
votes
0
answers
28
views
Problem with double-mesh and error estimation
I am writing a Matlab code for a first-order nonlinear singularly perturbed parameterized problem with integral boundary condition. I have successfully achieved the desired order of convergence for ...
-1
votes
3
answers
60
views
Formula to iterate the input range and stack the results into a column
Demonstration of what the result should look like:
I need a formula in Google Sheets that iterates each input from input range, the look-up results for every single input will be stacked into a ...
0
votes
0
answers
61
views
Loop over grouped data in R
I have two dataframes, one where id is a primary identifier and the other is long data. I merged both and so I have long data (this can be reversed). I grouped the data based on id and want to loop ...
0
votes
0
answers
24
views
Efficient method for sharding BigQuery table collection
I would like to ask for advice regarding the following task: assume a collection of BQ tables bearing names with structure name_YYYYMM and containing each a DATETIME type column called date_time whose ...
0
votes
2
answers
38
views
How to validate JSON response using JSON test data file?
Having JSON response with nested elements. I would like to validate it against JSON test data using Postman and test functions.
For the moment I can easily reach it by hardcoding:
const jsonData = pm....
0
votes
2
answers
36
views
how do i create and append to a new dataframe utilizing a iteration loop to extract of data?
i want to have a basic direct method to use different criteria to form new dataframes which i will display in a simple pie chart. i have such a feeble grasp of the topic that it seems to be difficult ...
0
votes
1
answer
34
views
What is the best way to have different entry points for a list of iterative commands?
I have a list of iterative Python commands:
def command_list(start_at):
step1
step2
step3
# ...
stepN
Now I want to start_at different steps in this list of commands and then ...
2
votes
1
answer
70
views
Tidying data frame with multiple variables within multiple columns
I'm working with a "molten" data frame, though perhaps "volcano" is a more apt description of it.
Basically, there are two columns in this data frame that break the first rule of ...
1
vote
2
answers
43
views
Check if greatest rolling change is less than a specific number in dataframe
I have a dataframe of a time series of stock prices and need to see at any point in time if the change (whether it be pct_change(1), pct_change(2), ... , pct_change(7) is less than 20%).
The logic I ...
0
votes
0
answers
18
views
How to load multiple .mat files with different suffix once I selected a starting file?
I have the following problem which I do not know how to approach:
I have a folder with four .mat files like this:
LeCroy000_000_ch1.mat
LeCroy000_000_ch2.mat
LeCroy000_001_ch1.mat
LeCroy000_001_ch2....
1
vote
1
answer
51
views
Netlogo: efficient iteration using 'foreach'
I want to calculate and store two certain quantities associated with turtles' properties, namely count how many turtles meet a condition and the sum of these turtles' specific attribute. That specific ...
0
votes
3
answers
90
views
I have a query to generate sequence of dates based on a given start date. I want to run the same query for all other dates and union the results
I have table1 with startdates in a column
10/02/2023
StartDate
04/02/2023
15/03/2023
I have around 500 values in this table.
I need an extra column which will generates by adding a month to the ...
1
vote
1
answer
95
views
Improving performance of iteration in R
I originally created a for loop to calculate numerous variables that were sometimes dependent on previous iterations e.g. [i] and [i-1].
To improve the performance for larger datasets I attempted to ...
0
votes
0
answers
29
views
Mongodb iterative methods inside aggregate pipeline
Hi so I am working on a database and we have 100k entries where the structure looks similar to
dict = {
'testResults': {
'test_1':1, #1 or 0 if a test passed/failed ...
1
vote
2
answers
63
views
Iterate along the two vectors of different length using map()
I have two vectors of unequal length. One vector is a list of dataframes and the other vector is made up of unique values. How can I use map() to iterate the vectors over a custom function? Dummy data ...
-1
votes
1
answer
83
views
C# - WPF - Display list of strings
When I search the equivalent of foreach in xaml WPF, I get ItemControl tutorials, but it is only about presentation
it does not solve the iteration part of it
how do I do this in WPF ???
<TextBox ...
0
votes
1
answer
30
views
Space Optimization for Iterative Depth-First-Search (DFS)
Problem
In most academic literature, the preferred DFS algorithm is always recursive, however, for large Graphs, an iterative variation using a Stack seems much more practical to me, without running ...
0
votes
1
answer
29
views
compilation process in some java question about relate to 2d arrays
public static boolean ContainedArr(boolean[][] photo, boolean[][] sub) { //find if sub is sub array in photo
if (sub.length>photo.length ||sub[0].length>photo[0].length) { //sub bigger ...
2
votes
3
answers
76
views
Is there a way to make combinations of paste0 function with a list?
I have a vector of names:
names <- c("a", "b", "c", "d", "e", "f", "g", "h")
I want to make series of combinations ...
0
votes
0
answers
22
views
Is there a reason that Python allows indexing the class list itself? [duplicate]
I have come across a "feature" of Python that allows one to index the list class (and all classes that implement __getitem__() AFAIK). It took me a non-trivial amount of time to uncover that ...
0
votes
0
answers
21
views
When combining iteration and recursion, how do I express the recursion via tail calls?
I am working on a practice problem and I have found a recursive solution. However, I can't figure out how to express the solution as tail recursion.
I think that the issue that I am having can be ...
3
votes
0
answers
54
views
Python: Iterating through 2 lists
I am trying to implement the following equation:
Where zc is an equally spaced range of values e.g.
t_array = np.arange(z_[0],z_[-1],0.01)
In this case
z_[0] = -15.336
z_[-1] = 15.336
I'm struggling ...
2
votes
2
answers
50
views
Substituting number of simulations (n) in rnorm() using a list of predetermined values
I'm using rnorm() but instead of substituting the number of simulations n with just one variable, I would like to do this multiple times with n having predetermined values from a series of values. (...
0
votes
0
answers
46
views
Iterating a Landsat image collection to display as a layer in google earth engine
I am working with Landsat 8/9 in Google Earth Engine (GEE) and would like some help. I have a list of Landsat images and want to do dNBR calculations to each of them and later displaying each as a ...
-1
votes
1
answer
36
views
LibreOffice Calc - Check if event date is in period of time and return event attribute
In spreadsheet like this:
A
B
C
D
E
1
Shift start
Shift end
Sum of event durations on that shift (min)
2
01.03.2024 15:35
02.03.2024 08:00
105
3
13.03.2024 15:35
14.03.2024 08:00
120
4
28.03....
0
votes
1
answer
65
views
DFS (Depth-first search) vs BFS (Breadth-first search) Space Optimizations
Problem
I am currently digging deep into some optimizations on the classical iterative approaches to both DFS and BFS algorithms. The material I'm currently using at my University presents both ...
-4
votes
1
answer
86
views
C# For loop with try catch finally
I am trying to run for loop for every 5 secs to get the readings from COM port. When successful getting the readings only once. Would like to run the loop even if there is error. sometimes the ...
1
vote
1
answer
82
views
Can Excel functions solve iterative problems?
I want to use Microsoft Excel to project the growth of a pig farming project into which I will inject a fixed amount of cash per month and then use the cash to raise the number of full pigs that the ...
0
votes
0
answers
22
views
Advanced if statements based on opened files
I am trying to encrypt the contents of an Excel file through iteration in a for loop, but I keep getting the error:
TypeError: 'NoneType' object is not iterable
My code:
import tkinter
import random
...
0
votes
0
answers
29
views
Update Blank Values Until the Next Populated Row PHP/MySQL
I don't know how to explain it well, or how to even ask. Here's some of my data:
+------------+------------------------+
| Department | Product Number |
+------------+------------------------+
...
0
votes
2
answers
32
views
Setting the counter (j) for (inner for loop)
enter image description hereCan anyone tell me why we should set the counter j in the inner for loop to (i+1) not (i=0) (beacause I think setting j to i = 0 will get all elements in the array).
And ...
0
votes
0
answers
59
views
How would I apply a rather complex summation formula like this in Excel?
This is the data table I am working with.
This is the formula I need to apply in Excel.
I want to clarify some notations. k_p_x means the probability that the individual aged x will survive for the ...
-1
votes
2
answers
73
views
Going back to an earlier index in list iteration
I have this loop over a list:
MyList = ["test", "test2", "test3", "test4", "test5", "test6", "test7"]
for item in MyList:
...
0
votes
0
answers
66
views
Iteratively output (print to screen) pyspark dataframes via .toPandas()
I'm working in an .iypnb with pyspark and pandas.
I'd like to be able to take my dataset (df) and loop through various columns, outputting a freq table of the values within that column.
Doing so with ....
2
votes
2
answers
272
views
Why next(iter(train_dataloader)) takes long execution time in PyTorch
I am trying to load a local dataset with images (around 225 images in total) using the following code:
# Set the batch size
BATCH_SIZE = 32
# Create data loaders
train_dataloader, test_dataloader, ...
-2
votes
2
answers
100
views
Python: best way to iterate through lists and store which has max value for each index
In Python (3.8), I have 15 lists of the same length.
Each list contains floats.
Here for the example, I will pretend I have 3 lists of length 5 to demonstrate my problem:
List1 = [29.561801, 29.564141,...
0
votes
1
answer
72
views
iterate through a csv file using numpy
I have a CSV file with 4 columns with x, y positions for tracks.
The 1st column is the ID of the track. The 2nd column is time. 3rd and 4th are X & Y co-ordinates.
Now the X & Y positions ...