Category "loops"

Object declaration in a loop for different ML models

Can anyone help me out, how can I perform the following task? I am getting an error TypeError: 'str' object is not callable models = ['LogisticRegression','Rand

Can numpy.tensordot or ufunc replace this nested for loop?

Note: I know this is very similar to Use numpy.tensordot to replace a nested loop , only that the actual instance we are working on seemed different( I need qua

How to Paste string of values in single cell of Excel using VBA

I have 2 sheets named "Target Data" and "Pivot". I have filtered data in "Target Data" and now want to copy only visible cells in single cell of "Pivot" sheet.

How to find a value of a key in a nested dictionary with lists?

There's some very strange json payloads that I need to parse and I'm complete stuck.. Say I have a nested dictionary with lists that looks like this: test_dict1

Visual Basic loop sum of integers ^ 2 till user input. power of 2

I need help with one simple task: Input an integer number n and output the sum: 1 + 2^2 + 3^2 + ... + n^2. Use input validation for n to be positive. My code d

Break statement not taking me outside of loop java

I am solving this problem on code forces. https://codeforces.com/contest/1675/problem/B The break statement I have doesn't break out of the while loop. When I u

How to do a Join and a Loop corectly using R

I have two sets of data that have a column mean_wage in common, but they are described differently. First one as 1 (wage), 2, 2.4 ... and the other one as 1256.

Transform code of two loops ("For") with lapply or sapply

I am learning how to code in R and I have written a piece of code that calculate the Net Present Value (NPV) of various assets at different points in time, give

C text formatter characters count is off

So I have an assignment to format text according to rules and eventually print out the number of characters in the string (including \n and spaces, anything but

Looping a function/analysis in R by unique column values

I am trying to sort people in my dataset into three body-size categories (Small, Medium, Large). Consider the toy example below: library(ggplot2) library(dplyr)

How to skip an item in nested map based on When()

I want iterate over items's data and create a a new list of SomeData based on item.type however when type is UNKNOWN I need skip that element and not add to lis

Could using native browser modal dialogs in a loop lead to potentially infinite execution?

I was trying some code at JSBin and got weird results. This should work - it's a simple loop that uses Window.prompt. It does execute the correct number of time

How do I average the elements that are above a threshold in an array?

I am trying to average all the elements that are above 150 in an array. I can't figure out how to make it all work out and output the correct numbers. Can anyon

How do I average the elements that are above a threshold in an array?

I am trying to average all the elements that are above 150 in an array. I can't figure out how to make it all work out and output the correct numbers. Can anyon

Instancing objects with loop and get one dataframe from it

I have defined a class "Scraper" and the method "scraping" contained in it outputs a list with price information ("results"). My objects are several online shop

Extract ID from multiple fasta file and save in seperate text file with existing name using python

I am having multiple fasta file with extension .fna, I want to extract Id only and save in multiple text file respectively, how it can be done using python, Fil

How to use tqdm in bash for loops?

I have this for loop for example that takes so much time to finish so I want to use tqdm to have a nice progress bar like in python. But I can't find any way to

Are infinite for loops possible in Python?

Is it possible to get an infinite loop in for loop? My guess is that there can be an infinite for loop in Python. I'd like to know this for future references.

The loop over two arrays take LONG

Thanks for your helps, I have two arrays: A (100k row, 10 col) and B (100k row, 12 col) The following code (thanks to BSALV) loop through A and B => It takes

Target Individual Form Instance/Counter Inside A PHP While Loop

I have a PDO prepared statement that I use on a single-image page where a user is going to be able to download that specific image. I currently have a counter t