Questions tagged [loops]
The loops tag has no usage guidance.
8
questions
0
votes
1
answer
62
views
Replace iterrow loops in pandas matrices with something else to shorten the running time
This post is modified from this one: https://codereview.stackexchange.com/posts/292885/edit (Alternatives to iterrow loops in python pandas dataframes).
I have a piece of code to calculate price ...
5
votes
2
answers
632
views
Alternatives to iterrow loops in python pandas dataframes
I have a piece of code to calculate price sensitivity based on the product and its rating.
Below is the original data set with product type, reported year, customer’s rating, price per unit, and ...
7
votes
5
answers
3k
views
Check if license plate number is formatted correctly
I'm just learning Python and am looking for some feedback on some of the code exercises I've completed and do work. In particular, what would make them more Pythonic, or more closely align with ...
2
votes
1
answer
37
views
Maintain a log containing values if certain conditions are met
I'm trying to capture profits and set a stop loss in my trading strategy. I want the stop loss to be set daily based on the past data and if the current price, i.e., price for the date falls below the ...
3
votes
1
answer
96
views
In Java, replace for loop with condition with lambdas [closed]
I want to replace a for loop with a break/return condition inside with a lambda.
I think I have a good replacement, but I want ...
2
votes
1
answer
185
views
Hackerrank "New Year chaos" solution - permute sequence by swapping adjacent terms
I was doing the Hackerrank "New Year chaos" problem. Here is the description:
It is New Year's Day and people are in line for the Wonderland
rollercoaster ride. Each person wears a sticker ...
3
votes
1
answer
114
views
Performing tasks on for-loop over thousands of items in Rcpp
I am trying to adapt an R script that I wrote to perform several tasks in a for-loop. The for-loop run over thousands of items, for about 900 times, therefore I would like to optimise my code at the ...
3
votes
2
answers
295
views
Calculate the base 10 log with loops in Java without using Math
I'm looking for a simple way to calculate the logarithm without using java.lang.Math, just out of interest.
Here's my try (I adopted some code parts from this ...